Passed
Push — master ( a7cb7c...0e8d9a )
by Jan-Marten
02:15
created

OperationFailure::__construct()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 6
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 3
CRAP Score 1

Importance

Changes 0
Metric Value
cc 1
eloc 2
nc 1
nop 2
dl 0
loc 6
ccs 3
cts 3
cp 1
crap 1
rs 10
c 0
b 0
f 0
1
<?php
2
/**
3
 * Copyright MediaCT. All rights reserved.
4
 * https://www.mediact.nl
5
 */
6
7
namespace Johmanx10\Transaction;
8
9
use Throwable;
10
11
class OperationFailure implements OperationFailureInterface
12
{
13
    /** @var OperationInterface */
14
    private $operation;
15
16
    /** @var Throwable|null */
17
    private $exception;
18
19
    /**
20
     * Constructor.
21
     *
22
     * @param OperationInterface $operation
23
     * @param Throwable|null     $exception
24
     */
25 2
    public function __construct(
26
        OperationInterface $operation,
27
        ?Throwable $exception
28
    ) {
29 2
        $this->operation = $operation;
30 2
        $this->exception = $exception;
31 2
    }
32
33
    /**
34
     * Get the failed operation.
35
     *
36
     * @return OperationInterface
37
     */
38 2
    public function getOperation(): OperationInterface
39
    {
40 2
        return $this->operation;
41
    }
42
43
    /**
44
     * Get the exception that caused the operation to fail.
45
     *
46
     * @return Throwable|null
47
     */
48 2
    public function getException(): ?Throwable
49
    {
50 2
        return $this->exception;
51
    }
52
}
53