Passed
Push — master ( e3dd73...0b1820 )
by Pol
01:36
created

Current   A

Complexity

Total Complexity 2

Size/Duplication

Total Lines 20
Duplicated Lines 0 %

Test Coverage

Coverage 100%

Importance

Changes 1
Bugs 0 Features 0
Metric Value
eloc 7
c 1
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 of() 0 15 2
1
<?php
2
3
declare(strict_types=1);
4
5
namespace loophp\fpt;
6
7
use Closure;
8
9
// phpcs:disable Generic.Files.LineLength.TooLong
10
11
/**
12
 * @psalm-immutable
13
 *
14
 * @psalm-template T
15
 */
16
final class Current
17
{
18
    /**
19
     * @psalm-pure
20
     */
21 1
    public static function of(): Closure
22
    {
23
        return
24
            /**
25
             * @psalm-param iterable<T> $iterable
26
             * @psalm-return ?T
27
             */
28 1
            static function (iterable $iterable) {
29 1
                $current = null;
30
31 1
                foreach ($iterable as $current) {
32 1
                    break;
33
                }
34
35 1
                return $current;
36 1
            };
37
    }
38
}
39