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

EqualsEmpty::getOperator()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 3
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 2
CRAP Score 1

Importance

Changes 0
Metric Value
cc 1
eloc 1
nc 1
nop 0
dl 0
loc 3
ccs 2
cts 2
cp 1
crap 1
rs 10
c 0
b 0
f 0
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