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

Combinators::reverseArgs()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 3
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 0
CRAP Score 2

Importance

Changes 1
Bugs 1 Features 0
Metric Value
cc 1
eloc 1
c 1
b 1
f 0
nc 1
nop 1
dl 0
loc 3
ccs 0
cts 2
cp 0
crap 2
rs 10
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