Passed
Pull Request — master (#5)
by Jan-Marten
05:15
created

OperationException   A

Complexity

Total Complexity 2

Size/Duplication

Total Lines 31
Duplicated Lines 0 %

Test Coverage

Coverage 100%

Importance

Changes 1
Bugs 0 Features 0
Metric Value
eloc 6
c 1
b 0
f 0
dl 0
loc 31
ccs 6
cts 6
cp 1
rs 10
wmc 2

2 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 7 1
A getOperation() 0 3 1
1
<?php
2
/**
3
 * Copyright MediaCT. All rights reserved.
4
 * https://www.mediact.nl
5
 */
6
7
namespace Johmanx10\Transaction\Exception;
8
9
use Johmanx10\Transaction\OperationInterface;
10
use RuntimeException;
11
use Throwable;
12
13
class OperationException extends RuntimeException implements
14
    OperationExceptionInterface
15
{
16
    /** @var OperationInterface|null */
17
    private $operation;
18
19
    /**
20
     * Constructor.
21
     *
22
     * @param string                  $message
23
     * @param OperationInterface|null $operation
24
     * @param Throwable|null          $previous
25
     */
26 1
    public function __construct(
27
        string $message,
28
        ?OperationInterface $operation,
29
        Throwable $previous = null
30
    ) {
31 1
        $this->operation = $operation;
32 1
        parent::__construct($message, 0, $previous);
33 1
    }
34
35
    /**
36
     * Get the operation that caused the exception to occur.
37
     * Returns null if the operation cannot be determined.
38
     *
39
     * @return OperationInterface|null
40
     */
41 1
    public function getOperation(): ?OperationInterface
42
    {
43 1
        return $this->operation;
44
    }
45
}
46