DeletePropertyMutation   A
last analyzed

Complexity

Total Complexity 4

Size/Duplication

Total Lines 20
Duplicated Lines 0 %

Test Coverage

Coverage 0%

Importance

Changes 0
Metric Value
eloc 6
c 0
b 0
f 0
dl 0
loc 20
ccs 0
cts 9
cp 0
rs 10
wmc 4

3 Methods

Rating   Name   Duplication   Size   Complexity  
A reset() 0 2 1
A __invoke() 0 6 2
A __construct() 0 3 1
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