FoldLeft1   A
last analyzed

Complexity

Total Complexity 1

Size/Duplication

Total Lines 24
Duplicated Lines 0 %

Test Coverage

Coverage 100%

Importance

Changes 0
Metric Value
eloc 7
c 0
b 0
f 0
dl 0
loc 24
ccs 8
cts 8
cp 1
rs 10
wmc 1

1 Method

Rating   Name   Duplication   Size   Complexity  
A __invoke() 0 17 1
1
<?php
2
3
declare(strict_types=1);
4
5
namespace loophp\collection\Operation;
6
7
use Closure;
8
use Generator;
9
10
/**
11
 * @immutable
12
 *
13
 * @template TKey
14
 * @template T
15
 */
16
final class FoldLeft1 extends AbstractOperation
17
{
18
    /**
19
     * @template V
20
     *
21
     * @return Closure(callable((T|V), T, TKey, iterable<TKey, T>): V): Closure(iterable<TKey, T>): Generator<int|TKey, V>
22
     */
23 30
    public function __invoke(): Closure
24
    {
25 30
        return
26
            /**
27
             * @param callable((T|V), T, TKey, iterable<TKey, T>): V $callback
28
             *
29
             * @return Closure(iterable<TKey, T>): Generator<int|TKey, V>
30
             */
31 30
            static function (callable $callback): Closure {
32
                /** @var Closure(iterable<TKey, T>):(Generator<int|TKey, V>) $pipe */
33 30
                $pipe = (new Pipe())()(
34 30
                    (new ScanLeft1())()($callback),
35 30
                    (new Last())()
36 30
                );
37
38
                // Point free style.
39 30
                return $pipe;
40 30
            };
41
    }
42
}
43