Processor::__construct()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 3
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 2
CRAP Score 1

Importance

Changes 1
Bugs 0 Features 0
Metric Value
cc 1
eloc 1
c 1
b 0
f 0
nc 1
nop 1
dl 0
loc 3
ccs 2
cts 2
cp 1
crap 1
rs 10
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