Strict::__invoke()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 13
Code Lines 3

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 4
CRAP Score 1

Importance

Changes 1
Bugs 0 Features 0
Metric Value
cc 1
eloc 3
c 1
b 0
f 0
nc 1
nop 0
dl 0
loc 13
ccs 4
cts 4
cp 1
crap 1
rs 10
1
<?php
2
3
declare(strict_types=1);
4
5
namespace loophp\collection\Operation;
6
7
use Closure;
8
use Generator;
9
use loophp\iterators\IterableIteratorAggregate;
10
use loophp\iterators\TypedIterableAggregate;
11
12
/**
13
 * @immutable
14
 *
15
 * @template TKey
16
 * @template T
17
 */
18
final class Strict extends AbstractOperation
19
{
20
    /**
21
     * @return Closure(null|callable(mixed): string): Closure(iterable<TKey, T>): Generator<TKey, T>
22
     */
23 4
    public function __invoke(): Closure
24
    {
25 4
        return
26
            /**
27
             * @param null|callable(mixed): string $callback
28
             *
29
             * @return Closure(iterable<TKey, T>): Generator<TKey, T>
30
             */
31 4
            static fn (?callable $callback = null): Closure =>
32
                /**
33
                 * @return Generator<TKey, T>
34
                 */
35 4
                static fn (iterable $iterator): Generator => yield from new TypedIterableAggregate((new IterableIteratorAggregate($iterator))->getIterator(), $callback);
36
    }
37
}
38