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

ValueWalker   A

Complexity

Total Complexity 3

Size/Duplication

Total Lines 15
Duplicated Lines 0 %

Importance

Changes 0
Metric Value
eloc 4
dl 0
loc 15
rs 10
c 0
b 0
f 0
wmc 3

2 Methods

Rating   Name   Duplication   Size   Complexity  
A createMutableEventIterator() 0 7 2
A createEventIterator() 0 3 1
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