-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathResult.php
38 lines (31 loc) · 846 Bytes
/
Result.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
<?php
declare(strict_types=1);
namespace Remorhaz\JSON\Patch\Result;
use Remorhaz\JSON\Data\Export\ValueDecoderInterface;
use Remorhaz\JSON\Data\Export\ValueEncoderInterface;
use Remorhaz\JSON\Data\Value\NodeValueInterface;
final class Result implements ResultInterface
{
public function __construct(
private readonly NodeValueInterface $value,
private readonly ValueEncoderInterface $encoder,
private readonly ValueDecoderInterface $decoder,
) {
}
public function encode(): string
{
return $this
->encoder
->exportValue($this->value);
}
public function decode(): mixed
{
return $this
->decoder
->exportValue($this->value);
}
public function get(): NodeValueInterface
{
return $this->value;
}
}