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

OperationException::__construct()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 7
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 3
CRAP Score 1

Importance

Changes 1
Bugs 0 Features 0
Metric Value
cc 1
eloc 2
c 1
b 0
f 0
nc 1
nop 3
dl 0
loc 7
ccs 3
cts 3
cp 1
crap 1
rs 10
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