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

Args   A

Complexity

Total Complexity 1

Size/Duplication

Total Lines 22
Duplicated Lines 0 %

Test Coverage

Coverage 100%

Importance

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

1 Method

Rating   Name   Duplication   Size   Complexity  
A of() 0 17 1
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