Passed
Push — master ( b12585...f9c1cd )
by Edward
02:38
created

ValueWalker::createMutableEventIterator()   A

Complexity

Conditions 2
Paths 2

Size

Total Lines 7
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 2
eloc 2
nc 2
nop 3
dl 0
loc 7
rs 10
c 0
b 0
f 0
1
<?php
2
declare(strict_types=1);
3
4
namespace Remorhaz\JSON\Data\Walker;
5
6
use Iterator;
7
use Remorhaz\JSON\Data\Path\PathInterface;
8
use Remorhaz\JSON\Data\Value\NodeValueInterface;
9
10
final class ValueWalker implements ValueWalkerInterface
11
{
12
13
    public function createEventIterator(NodeValueInterface $value, PathInterface $path): Iterator
14
    {
15
        return (new EventGenerator($value, $path))();
16
    }
17
18
    public function createMutableEventIterator(
19
        NodeValueInterface $value,
20
        PathInterface $path,
21
        MutationInterface $modifier
22
    ): Iterator {
23
        foreach ($this->createEventIterator($value, $path) as $event) {
24
            yield from $modifier($event, $this);
25
        }
26
    }
27
}
28