Passed
Push — master ( 9e5c60...cc25de )
by Edward
11:49
created

getExpectedIndex()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 3
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
cc 1
eloc 1
nc 1
nop 0
dl 0
loc 3
rs 10
c 1
b 0
f 0
1
<?php
2
3
declare(strict_types=1);
4
5
namespace Remorhaz\JSON\Path\Value\Exception;
6
7
use LogicException;
8
use Remorhaz\JSON\Data\Value\NodeValueInterface;
9
use Throwable;
10
11
final class ValueInListWithAnotherOuterIndexException extends LogicException implements ExceptionInterface
12
{
13
14
    private $value;
15
16
    private $expectedIndex;
17
18
    private $actualIndex;
19
20
    public function __construct(
21
        NodeValueInterface $value,
22
        int $expectedIndex,
23
        int $actualIndex,
24
        Throwable $previous = null
25
    ) {
26
        $this->value = $value;
27
        $this->expectedIndex = $expectedIndex;
28
        $this->actualIndex = $actualIndex;
29
        parent::__construct($this->buildMessage(), 0, $previous);
30
    }
31
32
    private function buildMessage(): string
33
    {
34
        return "Value is already in list with outer index {$this->expectedIndex}, not {$this->actualIndex}";
35
    }
36
37
    public function getValue(): NodeValueInterface
38
    {
39
        return $this->value;
40
    }
41
42
    public function getExpectedIndex(): int
43
    {
44
        return $this->expectedIndex;
45
    }
46
47
    public function getActualIndex(): int
48
    {
49
        return $this->actualIndex;
50
    }
51
}
52