iterable_apply()   A
last analyzed

Complexity

Conditions 2
Paths 2

Size

Total Lines 6
Code Lines 3

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 4
CRAP Score 2

Importance

Changes 0
Metric Value
cc 2
eloc 3
nc 2
nop 2
dl 0
loc 6
ccs 4
cts 4
cp 1
crap 2
rs 10
c 0
b 0
f 0
1
<?php
2
3
declare(strict_types=1);
4
5
namespace Improved;
6
7
/**
8
 * Apply a callback to each element.
9
 *
10
 * @param iterable $iterable
11
 * @param callable $callback
12
 * @return \Generator
13
 */
14 6
function iterable_apply(iterable $iterable, callable $callback): \Generator
0 ignored issues
show
introduced by
Function Improved\iterable_apply() has parameter $iterable with no value type specified in iterable type iterable.
Loading history...
introduced by
Function Improved\iterable_apply() return type has no value type specified in iterable type Generator.
Loading history...
15
{
16 5
    foreach ($iterable as $key => $value) {
17 4
        call_user_func($callback, $value, $key);
18
19 4
        yield $key => $value;
20
    }
21
}
22