ResultNotFoundException::__construct()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 5
Code Lines 3

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 4
CRAP Score 1

Importance

Changes 0
Metric Value
cc 1
eloc 3
c 0
b 0
f 0
nc 1
nop 3
dl 0
loc 5
ccs 4
cts 4
cp 1
crap 1
rs 10
1
<?php
2
3
declare(strict_types=1);
4
5
namespace Remorhaz\JSON\Path\Value\Exception;
6
7
use OutOfRangeException;
8
use Remorhaz\JSON\Path\Value\ValueListInterface;
9
use Throwable;
10
11
final class ResultNotFoundException extends OutOfRangeException implements ExceptionInterface
12
{
13
14
    private $index;
15
16
    private $values;
17
18 6
    public function __construct(int $index, ValueListInterface $valueList, Throwable $previous = null)
19
    {
20 6
        $this->index = $index;
21 6
        $this->values = $valueList;
22 6
        parent::__construct($this->buildMessage(), 0, $previous);
23 6
    }
24
25 6
    private function buildMessage(): string
26
    {
27 6
        return "Result not found in list at position {$this->index}";
28
    }
29
30 1
    public function getIndex(): int
31
    {
32 1
        return $this->index;
33
    }
34
35 1
    public function getValues(): ValueListInterface
36
    {
37 1
        return $this->values;
38
    }
39
}
40