iterable_map()   A
last analyzed

Complexity

Conditions 2
Paths 2

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 3
CRAP Score 2

Importance

Changes 0
Metric Value
cc 2
eloc 2
nc 2
nop 2
dl 0
loc 4
ccs 3
cts 3
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
 * Applies the callback to the elements of the iterator, replacing the value.
9
 *
10
 * @param iterable $iterable
11
 * @param callable $callback
12
 * @return \Generator
13
 */
14 11
function iterable_map(iterable $iterable, callable $callback): \Generator
0 ignored issues
show
introduced by
Function Improved\iterable_map() has parameter $iterable with no value type specified in iterable type iterable.
Loading history...
introduced by
Function Improved\iterable_map() return type has no value type specified in iterable type Generator.
Loading history...
15
{
16 10
    foreach ($iterable as $key => $value) {
17 9
        yield $key => call_user_func($callback, $value, $key);
18
    }
19
}
20