Passed
Push — master ( f875e6...bf0233 )
by Edward
05:26
created

SelectResult::get()   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 0
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 0
b 0
f 0
1
<?php
2
declare(strict_types=1);
3
4
namespace Remorhaz\JSON\Path\Processor\Result;
5
6
use function array_map;
7
use Remorhaz\JSON\Data\Export\ValueDecoderInterface;
8
use Remorhaz\JSON\Data\Export\ValueEncoderInterface;
9
use Remorhaz\JSON\Data\Value\ValueInterface;
10
11
final class SelectResult implements SelectResultInterface
12
{
13
14
    private $encoder;
15
16
    private $decoder;
17
18
    private $values;
19
20 7
    public function __construct(
21
        ValueEncoderInterface $encoder,
22
        ValueDecoderInterface $decoder,
23
        ValueInterface ...$values
24
    ) {
25 7
        $this->encoder = $encoder;
26 7
        $this->decoder = $decoder;
27 7
        $this->values = $values;
28 7
    }
29
30
    /**
31
     * {@inheritDoc}
32
     *
33
     * @return array
34
     */
35 2
    public function decode(): array
36
    {
37 2
        return array_map([$this->decoder, 'exportValue'], $this->values);
38
    }
39
40
    /**
41
     * {@inheritDoc}
42
     *
43
     * @return string[]
44
     */
45 3
    public function encode(): array
46
    {
47 3
        return array_map([$this->encoder, 'exportValue'], $this->values);
48
    }
49
50
    /**
51
     * {@inheritDoc}
52
     *
53
     * @return ValueInterface[]
54
     */
55 2
    public function get(): array
56
    {
57 2
        return $this->values;
58
    }
59
}
60