ArrayTrait::makeArrayWithKeys()   A
last analyzed

Complexity

Conditions 2
Paths 2

Size

Total Lines 8
Code Lines 4

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 0
CRAP Score 6

Importance

Changes 1
Bugs 0 Features 0
Metric Value
cc 2
eloc 4
c 1
b 0
f 0
nc 2
nop 2
dl 0
loc 8
ccs 0
cts 4
cp 0
crap 6
rs 10
1
<?php
2
3
namespace App\Traits;
4
5
use Closure;
6
trait ArrayTrait {
7
    protected function makeArrayWithKeys(array $array, Closure $idFunc) {
8
        $result = [ ];
9
10
        foreach($array as $item) {
11
            $result[$idFunc($item)] = $item;
12
        }
13
14
        return $result;
15
    }
16
}