-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathQueryFactory.php
47 lines (40 loc) · 1.49 KB
/
QueryFactory.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
39
40
41
42
43
44
45
46
47
<?php
declare(strict_types=1);
namespace Remorhaz\JSON\Patch\Query;
use Collator;
use Remorhaz\JSON\Data\Comparator\EqualValueComparator;
use Remorhaz\JSON\Data\Export\ValueDecoder;
use Remorhaz\JSON\Data\Export\ValueDecoderInterface;
use Remorhaz\JSON\Data\Export\ValueEncoder;
use Remorhaz\JSON\Data\Export\ValueEncoderInterface;
use Remorhaz\JSON\Data\Value\NodeValueInterface;
use Remorhaz\JSON\Patch\Operation\OperationFactory;
use Remorhaz\JSON\Patch\Operation\OperationFactoryInterface;
use Remorhaz\JSON\Pointer\Processor\Processor as PointerProcessor;
use Remorhaz\JSON\Pointer\Query\QueryFactory as PointerQueryFactory;
final class QueryFactory implements QueryFactoryInterface
{
public static function create(): QueryFactoryInterface
{
$decoder = new ValueDecoder();
return new self(
new OperationFactory(
PointerQueryFactory::create(),
PointerProcessor::create(),
new EqualValueComparator(new Collator('UTF-8')),
),
new ValueEncoder($decoder),
$decoder,
);
}
public function __construct(
private readonly OperationFactoryInterface $operationFactory,
private readonly ValueEncoderInterface $encoder,
private readonly ValueDecoderInterface $decoder,
) {
}
public function createQuery(NodeValueInterface $patch): QueryInterface
{
return new LazyQuery($this->operationFactory, $this->encoder, $this->decoder, $patch);
}
}