Nullsy   A
last analyzed

Complexity

Total Complexity 1

Size/Duplication

Total Lines 17
Duplicated Lines 0 %

Test Coverage

Coverage 100%

Importance

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

1 Method

Rating   Name   Duplication   Size   Complexity  
A __invoke() 0 7 1
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