LiteralValueList   A
last analyzed

Complexity

Total Complexity 6

Size/Duplication

Total Lines 36
Duplicated Lines 0 %

Test Coverage

Coverage 100%

Importance

Changes 1
Bugs 0 Features 0
Metric Value
eloc 11
c 1
b 0
f 0
dl 0
loc 36
ccs 15
cts 15
cp 1
rs 10
wmc 6

5 Methods

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