Completed
Push — master ( 1316f3...b7872d )
by Aydin
26s queued 12s
created

ArrayUtil::mapWithKeys()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 5
Code Lines 3

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
cc 1
eloc 3
c 1
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
class ArrayUtil
8
{
9
    public static function mapWithKeys(array $array, callable $callback) : array
10
    {
11
        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...
12
            array_keys($array),
13
            array_map($callback, array_keys($array), $array)
14
        );
15
    }
16
}
17