Reduce   A
last analyzed

Complexity

Total Complexity 1

Size/Duplication

Total Lines 28
Duplicated Lines 0 %

Test Coverage

Coverage 100%

Importance

Changes 3
Bugs 2 Features 0
Metric Value
eloc 5
c 3
b 2
f 0
dl 0
loc 28
ccs 5
cts 5
cp 1
rs 10
wmc 1

1 Method

Rating   Name   Duplication   Size   Complexity  
A __invoke() 0 21 1
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\ReduceIterableAggregate;
10
11
/**
12
 * @immutable
13
 *
14
 * @template TKey
15
 * @template T
16
 */
17
final class Reduce extends AbstractOperation
18
{
19
    /**
20
     * @template V
21
     *
22
     * @return Closure(callable(mixed, mixed, mixed, iterable<mixed, mixed>): mixed): Closure(mixed): Closure(iterable<TKey, T>): Generator<int, mixed>
23
     */
24 91
    public function __invoke(): Closure
25
    {
26 91
        return
27
            /**
28
             * @param callable(V, T, TKey, iterable<TKey, T>): V $callback
29
             *
30
             * @return Closure(V): Closure(iterable<TKey, T>): Generator<int, V>
31
             */
32 91
            static fn (callable $callback): Closure =>
33
                /**
34
                 * @param V $initial
0 ignored issues
show
Bug introduced by
The type loophp\collection\Operation\V was not found. Maybe you did not declare it correctly or list all dependencies?

The issue could also be caused by a filter entry in the build configuration. If the path has been excluded in your configuration, e.g. excluded_paths: ["lib/*"], you can move it to the dependency path list as follows:

filter:
    dependency_paths: ["lib/*"]

For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths

Loading history...
35
                 *
36
                 * @return Closure(iterable<TKey, T>): Generator<int, V>
37
                 */
38 91
                static fn (mixed $initial): Closure =>
39
                    /**
40
                     * @param iterable<TKey, T> $iterable
41
                     *
42
                     * @return Generator<int, V>
43
                     */
44 91
                    static fn (iterable $iterable): Generator => yield from new ReduceIterableAggregate($iterable, Closure::fromCallable($callback), $initial);
45
    }
46
}
47