Mutator   A
last analyzed

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