Completed
Push — master ( 1b9dfa...0adb34 )
by Aydin
21s queued 10s
created

mapWithKeys()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 5
Code Lines 3

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 1
eloc 3
c 0
b 0
f 0
nc 1
nop 2
dl 0
loc 5
rs 10
1
<?php
2
3
declare(strict_types=1);
4
5
namespace PhpSchool\CliMenu\Util;
6
7
function mapWithKeys(array $array, callable $callback) : array
8
{
9
    return array_combine(
0 ignored issues
show
Bug Best Practice introduced by
The expression return array_combine(arr..._keys($array), $array)) could return the type false which is incompatible with the type-hinted return array. Consider adding an additional type-check to rule them out.
Loading history...
10
        array_keys($array),
11
        array_map($callback, array_keys($array), $array)
12
    );
13
}
14
15
function each(array $array, callable $callback) : void
16
{
17
    foreach ($array as $k => $v) {
18
        $callback($k, $v);
19
    }
20
}
21