Passed
Push — master ( 5162f9...ff69b2 )
by Edward
05:25
created

ExistingResult   A

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