Passed
Push — master ( 3d52a7...3a32e2 )
by Edward
02:11
created

Mutator   A

Complexity

Total Complexity 2

Size/Duplication

Total Lines 22
Duplicated Lines 0 %

Test Coverage

Coverage 100%

Importance

Changes 1
Bugs 0 Features 0
Metric Value
eloc 11
c 1
b 0
f 0
dl 0
loc 22
ccs 9
cts 9
cp 1
rs 10
wmc 2

2 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 4 1
A mutate() 0 9 1
1
<?php
2
declare(strict_types=1);
3
4
namespace Remorhaz\JSON\Pointer\Processor\Mutator;
5
6
use Remorhaz\JSON\Data\Export\EventDecoderInterface;
7
use Remorhaz\JSON\Data\Path\Path;
8
use Remorhaz\JSON\Data\Value\NodeValueInterface;
9
use Remorhaz\JSON\Data\Walker\MutationInterface;
10
use Remorhaz\JSON\Data\Walker\ValueWalkerInterface;
11
12
final class Mutator implements MutatorInterface
13
{
14
15
    private $valueWalker;
16
17
    private $eventDecoder;
18
19 5
    public function __construct(ValueWalkerInterface $valueWalker, EventDecoderInterface $eventDecoder)
20
    {
21 5
        $this->valueWalker = $valueWalker;
22 5
        $this->eventDecoder = $eventDecoder;
23 5
    }
24
25 5
    public function mutate(NodeValueInterface $rootNode, MutationInterface $mutation): ?NodeValueInterface
26
    {
27
        $events = $this
28 5
            ->valueWalker
29 5
            ->createMutableEventIterator($rootNode, new Path, $mutation);
30
31
        return $this
32 5
            ->eventDecoder
33 5
            ->exportEvents($events);
34
    }
35
}
36