Passed
Push — master ( f6567e...6c178d )
by Edward
09:59 queued 07:10
created

NodeValueListBuilder::build()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 3
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 2
CRAP Score 1

Importance

Changes 1
Bugs 0 Features 1
Metric Value
cc 1
eloc 1
nc 1
nop 0
dl 0
loc 3
ccs 2
cts 2
cp 1
crap 1
rs 10
c 1
b 0
f 1
1
<?php
2
declare(strict_types=1);
3
4
namespace Remorhaz\JSON\Path\Value;
5
6
use Remorhaz\JSON\Data\Value\NodeValueInterface;
7
8
final class NodeValueListBuilder
9
{
10
11
    private $outerIndexes = [];
12
13
    private $values = [];
14
15 5
    public function addValue(NodeValueInterface $value, int $outerIndex): self
16
    {
17 5
        $this->outerIndexes[] = $outerIndex;
18 5
        $this->values[] = $value;
19
20 5
        return $this;
21
    }
22
23 6
    public function build(): NodeValueListInterface
24
    {
25 6
        return new NodeValueList(new IndexMap(...$this->outerIndexes), ...$this->values);
26
    }
27
}
28