Passed
Push — master ( f06de2...0ad1df )
by Alexander
02:43 queued 01:20
created

Not   A

Complexity

Total Complexity 3

Size/Duplication

Total Lines 18
Duplicated Lines 0 %

Test Coverage

Coverage 87.5%

Importance

Changes 0
Metric Value
eloc 7
dl 0
loc 18
ccs 7
cts 8
cp 0.875
rs 10
c 0
b 0
f 0
wmc 3

2 Methods

Rating   Name   Duplication   Size   Complexity  
A match() 0 10 2
A getOperator() 0 3 1
1
<?php
2
declare(strict_types=1);
3
4
namespace Yiisoft\Data\Reader\Iterable\Processor;
5
6
use Yiisoft\Data\Reader\Filter\FilterProcessorInterface;
7
8
class Not implements IterableProcessorInterface, FilterProcessorInterface
9
{
10
11 59
    public function getOperator(): string
12
    {
13 59
        return \YiiSoft\Data\Reader\Filter\Not::getOperator();
14
    }
15
16 1
    public function match(array $item, array $arguments, array $filterProcessors): bool
17
    {
18 1
        $operation = array_shift($arguments[0]);
19
20 1
        $processor = $filterProcessors[$operation] ?? null;
21 1
        if($processor === null) {
22
            throw new \RuntimeException(sprintf('Operation "%s" is not supported', $operation));
23
        }
24
        /* @var $processor IterableProcessorInterface */
25 1
        return !$processor->match($item, $arguments[0], $filterProcessors);
26
    }
27
28
}
29