Passed
Push — master ( 951d77...1f27ac )
by Alexander
02:35
created

EqualsEmpty   A

Complexity

Total Complexity 3

Size/Duplication

Total Lines 18
Duplicated Lines 0 %

Test Coverage

Coverage 100%

Importance

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

2 Methods

Rating   Name   Duplication   Size   Complexity  
A getOperator() 0 3 1
A match() 0 11 2
1
<?php
2
3
declare(strict_types=1);
4
5
namespace Yiisoft\Data\Reader\Iterable\Handler;
6
7
use InvalidArgumentException;
8
use Yiisoft\Data\Reader\FilterDataValidationHelper;
9
10
use function count;
11
12
final class EqualsEmpty implements IterableHandlerInterface
13
{
14 104
    public function getOperator(): string
15
    {
16 104
        return \Yiisoft\Data\Reader\Filter\EqualsEmpty::getOperator();
17
    }
18
19 21
    public function match(array|object $item, array $arguments, array $filterHandlers): bool
20
    {
21 21
        if (count($arguments) !== 1) {
22 4
            throw new InvalidArgumentException('$arguments should contain exactly one element.');
23
        }
24
25 17
        [$field] = $arguments;
26 17
        FilterDataValidationHelper::assertFieldIsString($field);
27
28
        /** @var string $field */
29 9
        return empty($item[$field]);
30
    }
31
}
32