Passed
Push — master ( f0feee...3c09de )
by Sergei
12:22
created

EqualsNullHandler::getFilterClass()   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
eloc 1
c 0
b 0
f 0
dl 0
loc 3
ccs 2
cts 2
cp 1
rs 10
cc 1
nc 1
nop 0
crap 1
1
<?php
2
3
declare(strict_types=1);
4
5
namespace Yiisoft\Data\Reader\Iterable\FilterHandler;
6
7
use Yiisoft\Arrays\ArrayHelper;
8
use Yiisoft\Data\Reader\Filter\EqualsNull;
9
use Yiisoft\Data\Reader\FilterInterface;
10
use Yiisoft\Data\Reader\Iterable\IterableFilterHandlerInterface;
11
12
/**
13
 * `EqualsNull` iterable filter handler checks that the item's field value is null.
14
 */
15
final class EqualsNullHandler implements IterableFilterHandlerInterface
16
{
17 143
    public function getFilterClass(): string
18
    {
19 143
        return EqualsNull::class;
20
    }
21
22 9
    public function match(array|object $item, FilterInterface $filter, array $iterableFilterHandlers): bool
23
    {
24
        /** @var EqualsNull $filter */
25
26 9
        return ArrayHelper::getValue($item, $filter->getField()) === null;
0 ignored issues
show
Bug introduced by
The method getField() does not exist on Yiisoft\Data\Reader\FilterInterface. It seems like you code against a sub-type of Yiisoft\Data\Reader\FilterInterface such as Yiisoft\Data\Reader\Filter\Like or Yiisoft\Data\Reader\Filter\Between or Yiisoft\Data\Reader\Filter\In or Yiisoft\Data\Reader\Filter\EqualsNull or Yiisoft\Data\Reader\Filter\Compare. ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-call  annotation

26
        return ArrayHelper::getValue($item, $filter->/** @scrutinizer ignore-call */ getField()) === null;
Loading history...
27
    }
28
}
29