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

ValueInListWithAnotherOuterIndexException   A

Complexity

Total Complexity 5

Size/Duplication

Total Lines 39
Duplicated Lines 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
eloc 12
dl 0
loc 39
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
    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