ExistingValueResult   A
last analyzed

Complexity

Total Complexity 5

Size/Duplication

Total Lines 41
Duplicated Lines 0 %

Test Coverage

Coverage 100%

Importance

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

5 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 8 1
A encode() 0 5 1
A decode() 0 5 1
A get() 0 3 1
A exists() 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
final class ExistingValueResult implements ValueResultInterface
12
{
13
14
    private $jsonEncoder;
15
16
    private $jsonDecoder;
17
18
    private $value;
19
20 6
    public function __construct(
21
        ValueEncoderInterface $jsonEncoder,
22
        ValueDecoderInterface $jsonDecoder,
23
        ValueInterface $value
24
    ) {
25 6
        $this->jsonEncoder = $jsonEncoder;
26 6
        $this->jsonDecoder = $jsonDecoder;
27 6
        $this->value = $value;
28 6
    }
29
30 1
    public function exists(): bool
31
    {
32 1
        return true;
33
    }
34
35 2
    public function encode(): string
36
    {
37
        return $this
38 2
            ->jsonEncoder
39 2
            ->exportValue($this->value);
40
    }
41
42 2
    public function decode()
43
    {
44
        return $this
45 2
            ->jsonDecoder
46 2
            ->exportValue($this->value);
47
    }
48
49 1
    public function get(): ValueInterface
50
    {
51 1
        return $this->value;
52
    }
53
}
54