Total Complexity | 5 |
Total Lines | 37 |
Duplicated Lines | 0 % |
Coverage | 100% |
Changes | 0 |
1 | <?php |
||
9 | class MatchedPatchOperation |
||
10 | { |
||
11 | private array $operationData; |
||
|
|||
12 | |||
13 | private PatchOperationHandler $handler; |
||
14 | |||
15 | 7 | private function __construct(array $operationData, PatchOperationHandler $handler) |
|
16 | { |
||
17 | 7 | $this->operationData = $operationData; |
|
18 | 7 | $this->handler = $handler; |
|
19 | } |
||
20 | |||
21 | 7 | public static function create(array $operationData, PatchOperationHandler $handler): MatchedPatchOperation |
|
24 | } |
||
25 | |||
26 | 4 | public function matchFor(string $operationName): bool |
|
27 | { |
||
28 | 4 | return $operationName === $this->handler->getName(); |
|
29 | } |
||
30 | |||
31 | /** |
||
32 | * call handle on the handler |
||
33 | */ |
||
34 | 3 | public function process(Patchable $patchable): void |
|
35 | { |
||
36 | 3 | $optionResolver = new OptionsResolver(); |
|
37 | 3 | $optionResolver->setRequired(['op']); |
|
38 | 3 | $this->handler->configureOptions($optionResolver); |
|
39 | 3 | $options = new OperationData($optionResolver->resolve($this->operationData)); |
|
40 | 3 | $this->handler->handle($patchable, $options); |
|
41 | } |
||
42 | |||
43 | 2 | public function getOpName(): string |
|
46 | } |
||
47 | } |
||
48 |