DeletePropertyMutation::__invoke()   A
last analyzed

Complexity

Conditions 2
Paths 2

Size

Total Lines 6
Code Lines 3

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 0
CRAP Score 6

Importance

Changes 0
Metric Value
cc 2
eloc 3
c 0
b 0
f 0
nc 2
nop 2
dl 0
loc 6
ccs 0
cts 4
cp 0
crap 6
rs 10
1
<?php
2
3
declare(strict_types=1);
4
5
namespace Remorhaz\JSON\Pointer\Processor\Mutator;
6
7
use Iterator;
8
use Remorhaz\JSON\Data\Event\EventInterface;
9
use Remorhaz\JSON\Data\Path\PathInterface;
10
use Remorhaz\JSON\Data\Walker\MutationInterface;
11
use Remorhaz\JSON\Data\Walker\ValueWalkerInterface;
12
13
final class DeletePropertyMutation implements MutationInterface
14
{
15
16
    private $path;
17
18
    public function __construct(PathInterface $path)
19
    {
20
        $this->path = $path;
21
    }
22
23
    public function __invoke(EventInterface $event, ValueWalkerInterface $valueWalker): Iterator
24
    {
25
        if ($this->path->contains($event->getPath())) {
26
            return;
27
        }
28
        yield $event;
29
    }
30
31
    public function reset(): void
32
    {
33
    }
34
}
35