Passed
Push — master ( 2ce733...d59a11 )
by Pol
02:11
created

Combinators   A

Complexity

Total Complexity 5

Size/Duplication

Total Lines 25
Duplicated Lines 0 %

Test Coverage

Coverage 0%

Importance

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

5 Methods

Rating   Name   Duplication   Size   Complexity  
A I() 0 3 1
A reverseArgs() 0 3 1
A Ki() 0 3 1
A extractArgs() 0 3 1
A K() 0 3 1
1
<?php
2
3
declare(strict_types=1);
4
5
namespace loophp\collection\Enum;
6
7
use Closure;
8
9
use function array_slice;
10
11
enum Combinators
12
{
13
    public static function extractArgs(Closure $f, int $offset = 0, int $length = 0): Closure
14
    {
15
        return static fn (...$args): mixed => $f(...array_slice($args, $offset, $length));
16
    }
17
18
    public static function I(): Closure
19
    {
20
        return static fn (...$a): mixed => current($a);
21
    }
22
23
    public static function K(): Closure
24
    {
25
        return static fn (...$a): Closure => static fn (...$b): mixed => current($a);
0 ignored issues
show
Unused Code introduced by
The parameter $b is not used and could be removed. ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-unused  annotation

25
        return static fn (...$a): Closure => static fn (/** @scrutinizer ignore-unused */ ...$b): mixed => current($a);

This check looks for parameters that have been defined for a function or method, but which are not used in the method body.

Loading history...
26
    }
27
28
    public static function Ki(): Closure
29
    {
30
        return static fn (...$a): Closure => static fn (...$b): mixed => current($b);
0 ignored issues
show
Unused Code introduced by
The parameter $a is not used and could be removed. ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-unused  annotation

30
        return static fn (/** @scrutinizer ignore-unused */ ...$a): Closure => static fn (...$b): mixed => current($b);

This check looks for parameters that have been defined for a function or method, but which are not used in the method body.

Loading history...
31
    }
32
33
    public static function reverseArgs(Closure $f): Closure
34
    {
35
        return static fn (...$args): mixed => $f(...array_reverse($args));
36
    }
37
}
38