Result::encode()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 5
Code Lines 3

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 3
CRAP Score 1

Importance

Changes 1
Bugs 0 Features 0
Metric Value
cc 1
eloc 3
c 1
b 0
f 0
nc 1
nop 0
dl 0
loc 5
ccs 3
cts 3
cp 1
crap 1
rs 10
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 5
    public function __construct(
20
        NodeValueInterface $value,
21
        ValueEncoderInterface $encoder,
22
        ValueDecoderInterface $decoder
23
    ) {
24 5
        $this->value = $value;
25 5
        $this->encoder = $encoder;
26 5
        $this->decoder = $decoder;
27 5
    }
28
29 2
    public function encode(): string
30
    {
31
        return $this
32 2
            ->encoder
33 2
            ->exportValue($this->value);
34
    }
35
36 2
    public function decode()
37
    {
38
        return $this
39 2
            ->decoder
40 2
            ->exportValue($this->value);
41
    }
42
43 1
    public function get(): NodeValueInterface
44
    {
45 1
        return $this->value;
46
    }
47
}
48