Unpair::__invoke()   A
last analyzed

Complexity

Conditions 2
Paths 1

Size

Total Lines 13
Code Lines 5

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 6
CRAP Score 2

Importance

Changes 0
Metric Value
cc 2
eloc 5
nc 1
nop 0
dl 0
loc 13
ccs 6
cts 6
cp 1
crap 2
rs 10
c 0
b 0
f 0
1
<?php
2
3
declare(strict_types=1);
4
5
namespace loophp\collection\Operation;
6
7
use Closure;
8
use Generator;
9
10
/**
11
 * @immutable
12
 *
13
 * @template TKey
14
 * @template T
15
 */
16
final class Unpair extends AbstractOperation
17
{
18
    /**
19
     * @return Closure(iterable<TKey, T>): Generator<int, (TKey|T), mixed, void>
20
     */
21 2
    public function __invoke(): Closure
22
    {
23 2
        return
24
            /**
25
             * @param iterable<TKey, T> $iterable
26
             *
27
             * @return Generator<int, (TKey|T), mixed, void>
28
             */
29 2
            static function (iterable $iterable): Generator {
30 2
                foreach ($iterable as $key => $value) {
31 2
                    yield $key;
32
33 2
                    yield $value;
34
                }
35 2
            };
36
    }
37
}
38