Completed
Push — master ( 0c0824...37a545 )
by Edward
04:26
created

ValueList   A

Complexity

Total Complexity 5

Size/Duplication

Total Lines 30
Duplicated Lines 0 %

Test Coverage

Coverage 100%

Importance

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

4 Methods

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