Diff   A
last analyzed

Complexity

Total Complexity 1

Size/Duplication

Total Lines 18
Duplicated Lines 0 %

Test Coverage

Coverage 100%

Importance

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

1 Method

Rating   Name   Duplication   Size   Complexity  
A __invoke() 0 13 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 Diff extends AbstractOperation
19
{
20
    /**
21
     * @return Closure(array<T>): Closure(iterable<TKey, T>): Generator<TKey, T>
22
     */
23 14
    public function __invoke(): Closure
24
    {
25 14
        return
26
            /**
27
             * @param array<T> $values
28
             *
29
             * @return Closure(iterable<TKey, T>): Generator<TKey, T>
30
             */
31 14
            static fn (array $values): Closure => (new Filter())()(
32
                /**
33
                 * @param T $value
34
                 */
35 14
                static fn (mixed $value): bool => !in_array($value, $values, true)
36 14
            );
37
    }
38
}
39