ExistingResult   A
last analyzed

Complexity

Total Complexity 5

Size/Duplication

Total Lines 41
Duplicated Lines 0 %

Test Coverage

Coverage 100%

Importance

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

5 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 8 1
A get() 0 3 1
A decode() 0 5 1
A encode() 0 5 1
A exists() 0 3 1
1
<?php
2
3
declare(strict_types=1);
4
5
namespace Remorhaz\JSON\Pointer\Processor\Result;
6
7
use Remorhaz\JSON\Data\Export\ValueDecoderInterface;
8
use Remorhaz\JSON\Data\Export\ValueEncoderInterface;
9
use Remorhaz\JSON\Data\Value\NodeValueInterface;
10
11
final class ExistingResult implements ResultInterface
12
{
13
14
    private $encoder;
15
16
    private $decoder;
17
18
    private $nodeValue;
19
20 6
    public function __construct(
21
        ValueEncoderInterface $encoder,
22
        ValueDecoderInterface $decoder,
23
        NodeValueInterface $nodeValue
24
    ) {
25 6
        $this->encoder = $encoder;
26 6
        $this->decoder = $decoder;
27 6
        $this->nodeValue = $nodeValue;
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
            ->encoder
39 2
            ->exportValue($this->nodeValue);
40
    }
41
42 2
    public function decode()
43
    {
44
        return $this
45 2
            ->decoder
46 2
            ->exportValue($this->nodeValue);
47
    }
48
49 1
    public function get(): NodeValueInterface
50
    {
51 1
        return $this->nodeValue;
52
    }
53
}
54