Passed
Push — master ( ec8827...deea55 )
by Edward
02:26
created

Result   A

Complexity

Total Complexity 4

Size/Duplication

Total Lines 36
Duplicated Lines 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
eloc 14
c 1
b 0
f 0
dl 0
loc 36
rs 10
wmc 4

4 Methods

Rating   Name   Duplication   Size   Complexity  
A decode() 0 5 1
A __construct() 0 8 1
A get() 0 3 1
A encode() 0 5 1
1
<?php
2
declare(strict_types=1);
3
4
namespace Remorhaz\JSON\Patch\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 Result implements ResultInterface
11
{
12
13
    private $value;
14
15
    private $encoder;
16
17
    private $decoder;
18
19
    public function __construct(
20
        NodeValueInterface $value,
21
        ValueEncoderInterface $encoder,
22
        ValueDecoderInterface $decoder
23
    ) {
24
        $this->value = $value;
25
        $this->encoder = $encoder;
26
        $this->decoder = $decoder;
27
    }
28
29
    public function encode(): string
30
    {
31
        return $this
32
            ->encoder
33
            ->exportValue($this->value);
34
    }
35
36
    public function decode()
37
    {
38
        return $this
39
            ->decoder
40
            ->exportValue($this->value);
41
    }
42
43
    public function get(): NodeValueInterface
44
    {
45
        return $this->value;
46
    }
47
}
48