LoopHelper   A
last analyzed

Complexity

Total Complexity 3

Size/Duplication

Total Lines 18
Duplicated Lines 0 %

Test Coverage

Coverage 100%

Importance

Changes 1
Bugs 0 Features 0
Metric Value
wmc 3
eloc 7
c 1
b 0
f 0
dl 0
loc 18
ccs 7
cts 7
cp 1
rs 10

1 Method

Rating   Name   Duplication   Size   Complexity  
A pairwise() 0 11 3
1
<?php
2
3
namespace Smoren\FormulaTools\Helpers;
4
5
class LoopHelper
6
{
7
    /**
8
     * @template T
9
     * @param array<T> $input
10
     * @return \Generator<array{T, T}>
11
     */
12 149
    public static function pairwise(array $input): \Generator
13
    {
14 149
        foreach ($input as $currentValue) {
15 148
            if (!isset($prevValue)) {
16 148
                $prevValue = $currentValue;
17 148
                continue;
18
            }
19
20 145
            yield [$prevValue, $currentValue];
21
22 121
            $prevValue = $currentValue;
23
        }
24
    }
25
}
26