NodeValueList   A
last analyzed

Complexity

Total Complexity 5

Size/Duplication

Total Lines 33
Duplicated Lines 0 %

Test Coverage

Coverage 100%

Importance

Changes 0
Metric Value
eloc 10
c 0
b 0
f 0
dl 0
loc 33
ccs 12
cts 12
cp 1
rs 10
wmc 5

4 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 4 1
A getValue() 0 7 2
A getIndexMap() 0 3 1
A getValues() 0 3 1
1
<?php
2
3
declare(strict_types=1);
4
5
namespace Remorhaz\JSON\Path\Value;
6
7
use Remorhaz\JSON\Data\Value\NodeValueInterface;
8
use Remorhaz\JSON\Data\Value\ValueInterface;
9
10
final class NodeValueList implements NodeValueListInterface
11
{
12
13
    private $values;
14
15
    private $indexMap;
16
17 5
    public function __construct(IndexMapInterface $indexMap, NodeValueInterface ...$values)
18
    {
19 5
        $this->values = $values;
20 5
        $this->indexMap = $indexMap;
21 5
    }
22
23 2
    public function getValue(int $index): ValueInterface
24
    {
25 2
        if (!isset($this->values[$index])) {
26 1
            throw new Exception\ValueNotFoundException($index, $this);
27
        }
28
29 1
        return $this->values[$index];
30
    }
31
32
    /**
33
     * @return ValueInterface[]
34
     */
35 2
    public function getValues(): array
36
    {
37 2
        return $this->values;
38
    }
39
40 1
    public function getIndexMap(): IndexMapInterface
41
    {
42 1
        return $this->indexMap;
43
    }
44
}
45