Nullsy::__invoke()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 7
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 3
CRAP Score 1

Importance

Changes 0
Metric Value
cc 1
eloc 2
nc 1
nop 0
dl 0
loc 7
ccs 3
cts 3
cp 1
crap 1
rs 10
c 0
b 0
f 0
1
<?php
2
3
declare(strict_types=1);
4
5
namespace loophp\collection\Operation;
6
7
use Closure;
8
use Generator;
9
10
use function in_array;
11
12
/**
13
 * @immutable
14
 *
15
 * @template TKey
16
 * @template T
17
 */
18
final class Nullsy extends AbstractOperation
19
{
20
    /**
21
     * @var array{0: null, 1: array<mixed>, 2: int, 3: bool, 4: string}
22
     */
23
    public const VALUES = [null, [], 0, false, ''];
24
25
    /**
26
     * @return Closure(iterable<TKey, T>): Generator<int, bool>
27
     */
28 8
    public function __invoke(): Closure
29
    {
30 8
        return (new Every())()(
31
            /**
32
             * @param T $value
33
             */
34 8
            static fn (int $index, mixed $value): bool => in_array((bool) $value, self::VALUES, true)
35 8
        );
36
    }
37
}
38