getValue()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 3
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 2
CRAP Score 1

Importance

Changes 1
Bugs 0 Features 0
Metric Value
cc 1
eloc 1
nc 1
nop 0
dl 0
loc 3
ccs 2
cts 2
cp 1
crap 1
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 7
    public function __construct(
21
        NodeValueInterface $value,
22
        int $expectedIndex,
23
        int $actualIndex,
24
        Throwable $previous = null
25
    ) {
26 7
        $this->value = $value;
27 7
        $this->expectedIndex = $expectedIndex;
28 7
        $this->actualIndex = $actualIndex;
29 7
        parent::__construct($this->buildMessage(), 0, $previous);
30 7
    }
31
32 7
    private function buildMessage(): string
33
    {
34 7
        return "Value is already in list with outer index {$this->expectedIndex}, not {$this->actualIndex}";
35
    }
36
37 1
    public function getValue(): NodeValueInterface
38
    {
39 1
        return $this->value;
40
    }
41
42 1
    public function getExpectedIndex(): int
43
    {
44 1
        return $this->expectedIndex;
45
    }
46
47 1
    public function getActualIndex(): int
48
    {
49 1
        return $this->actualIndex;
50
    }
51
}
52