Passed
Push — master ( 7db7a1...f2f5fa )
by Pol
07:16
created

Args::of()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 17
Code Lines 4

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 4
CRAP Score 1

Importance

Changes 1
Bugs 0 Features 0
Metric Value
cc 1
eloc 4
c 1
b 0
f 0
nc 1
nop 0
dl 0
loc 17
ccs 4
cts 4
cp 1
crap 1
rs 10
1
<?php
2
3
declare(strict_types=1);
4
5
namespace loophp\fpt;
6
7
use Closure;
8
9
use function array_slice;
10
11
// phpcs:disable Generic.Files.LineLength.TooLong
12
13
/**
14
 * @psalm-immutable
15
 *
16
 * @psalm-template T
17
 */
18
final class Args
19
{
20
    /**
21
     * @psalm-pure
22
     */
23 2
    public static function of(): Closure
24
    {
25
        return
26
            /**
27
             * @psalm-param positive-int $index
28
             */
29 2
            static fn (int $offset): Closure =>
30
                /**
31
                 * @psalm-param positive-int $index
32
                 */
33 2
                static fn (int $length): Closure =>
34
                    /**
35
                     * @psalm-param T ...$args
36
                     *
37
                     * @psalm-return T
38
                     */
39 2
                    static fn (...$args) => array_slice($args, $offset, $length, true);
40
    }
41
}
42