SelectResult   A
last analyzed

Complexity

Total Complexity 4

Size/Duplication

Total Lines 47
Duplicated Lines 0 %

Test Coverage

Coverage 100%

Importance

Changes 0
Metric Value
eloc 9
dl 0
loc 47
ccs 11
cts 11
cp 1
rs 10
c 0
b 0
f 0
wmc 4

4 Methods

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