CallbacksArrayReducer   A
last analyzed

Complexity

Total Complexity 2

Size/Duplication

Total Lines 20
Duplicated Lines 0 %

Test Coverage

Coverage 100%

Importance

Changes 8
Bugs 0 Features 0
Metric Value
eloc 7
c 8
b 0
f 0
dl 0
loc 20
ccs 6
cts 6
cp 1
rs 10
wmc 2

1 Method

Rating   Name   Duplication   Size   Complexity  
A or() 0 15 2
1
<?php
2
3
declare(strict_types=1);
4
5
namespace loophp\collection\Utils;
6
7
use Closure;
8
9
/**
10
 * @internal
11
 *
12
 * @immutable
13
 */
14
final class CallbacksArrayReducer
15
{
16
    /**
17
     * @return Closure(array<array-key, callable(mixed...): bool>): Closure(mixed...): bool
18
     */
19 360
    public static function or(): Closure
20
    {
21 360
        return
22
            /**
23
             * @param array<array-key, callable(mixed...): bool> $callbacks
0 ignored issues
show
Documentation Bug introduced by
The doc comment array<array-key, callable(mixed...): bool> at position 2 could not be parsed: Unknown type name 'array-key' at position 2 in array<array-key, callable(mixed...): bool>.
Loading history...
24
             *
25
             * @return Closure(mixed...): bool
26
             */
27 360
            static fn (array $callbacks): Closure => static fn (mixed ...$parameters): bool => array_reduce(
28 360
                $callbacks,
29
                /**
30
                 * @param callable(mixed...): bool $callable
31
                 */
32 360
                static fn (bool $carry, callable $callable): bool => $carry || $callable(...$parameters),
33 360
                false
34 360
            );
35
    }
36
}
37