Passed
Push — master ( ec8827...deea55 )
by Edward
02:26
created

TestFailedException::__construct()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 15
Code Lines 7

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
cc 1
eloc 7
c 1
b 0
f 0
nc 1
nop 5
dl 0
loc 15
rs 10
1
<?php
2
declare(strict_types=1);
3
4
namespace Remorhaz\JSON\Patch\Operation\Exception;
5
6
use Remorhaz\JSON\Data\Value\NodeValueInterface;
7
use RuntimeException;
8
use Throwable;
9
10
final class TestFailedException extends RuntimeException implements ExceptionInterface
11
{
12
13
    private $index;
14
15
    private $document;
16
17
    private $path;
18
19
    private $expectedValue;
20
21
    public function __construct(
22
        int $index,
23
        NodeValueInterface $document,
24
        string $path,
25
        NodeValueInterface $expectedValue,
26
        Throwable $previous = null
27
    ) {
28
        $this->index = $index;
29
        $this->document = $document;
30
        $this->path = $path;
31
        $this->expectedValue = $expectedValue;
32
        parent::__construct(
33
            "Operation #{$this->index}: test operation failed at '{$path}'",
34
            0,
35
            $previous
36
        );
37
    }
38
39
    public function getIndex(): int
40
    {
41
        return $this->index;
42
    }
43
44
    public function getDocument(): NodeValueInterface
45
    {
46
        return $this->document;
47
    }
48
49
    public function getPath(): string
50
    {
51
        return $this->path;
52
    }
53
54
    public function getExpectedValue(): NodeValueInterface
55
    {
56
        return $this->expectedValue;
57
    }
58
}
59