ValueInListWithAnotherOuterIndexException   A
last analyzed

Complexity

Total Complexity 5

Size/Duplication

Total Lines 39
Duplicated Lines 0 %

Test Coverage

Coverage 100%

Importance

Changes 1
Bugs 0 Features 0
Metric Value
eloc 12
dl 0
loc 39
ccs 14
cts 14
cp 1
rs 10
c 1
b 0
f 0
wmc 5

5 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 10 1
A getActualIndex() 0 3 1
A buildMessage() 0 3 1
A getExpectedIndex() 0 3 1
A getValue() 0 3 1
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