Processor   A
last analyzed

Complexity

Total Complexity 4

Size/Duplication

Total Lines 21
Duplicated Lines 0 %

Test Coverage

Coverage 100%

Importance

Changes 1
Bugs 0 Features 0
Metric Value
eloc 8
c 1
b 0
f 0
dl 0
loc 21
ccs 9
cts 9
cp 1
rs 10
wmc 4

3 Methods

Rating   Name   Duplication   Size   Complexity  
A create() 0 3 1
A apply() 0 6 2
A __construct() 0 3 1
1
<?php
2
3
namespace Remorhaz\JSON\Patch\Processor;
4
5
use Remorhaz\JSON\Data\Value\NodeValueInterface;
6
use Remorhaz\JSON\Patch\Query\QueryInterface;
7
use Remorhaz\JSON\Patch\Result\ResultInterface;
8
use Remorhaz\JSON\Pointer\Processor\Processor as PointerProcessor;
9
use Remorhaz\JSON\Pointer\Processor\ProcessorInterface as PointerProcessorInterface;
10
use Throwable;
11
12
class Processor implements ProcessorInterface
13
{
14
15
    private $pointerProcessor;
16
17 3
    public static function create(): ProcessorInterface
18
    {
19 3
        return new self(PointerProcessor::create());
20
    }
21
22 4
    public function __construct(PointerProcessorInterface $pointerProcessor)
23
    {
24 4
        $this->pointerProcessor = $pointerProcessor;
25 4
    }
26
27 3
    public function apply(QueryInterface $query, NodeValueInterface $data): ResultInterface
28
    {
29
        try {
30 3
            return $query($data, $this->pointerProcessor);
31 1
        } catch (Throwable $e) {
32 1
            throw new Exception\PatchNotAppliedException($e);
33
        }
34
    }
35
}
36