Completed
Push — master ( 77bf97...70e8e5 )
by Avtandil
02:17
created

Arr::map()   A

Complexity

Conditions 2
Paths 2

Size

Total Lines 9

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 0
CRAP Score 6

Importance

Changes 0
Metric Value
cc 2
nc 2
nop 2
dl 0
loc 9
ccs 0
cts 5
cp 0
crap 6
rs 9.9666
c 0
b 0
f 0
1
<?php
2
3
declare(strict_types=1);
4
5
namespace Longman\LaravelLodash\Support;
6
7
use Closure;
8
use Illuminate\Support\Arr as BaseArr;
9
use Traversable;
10
11
class Arr extends BaseArr
12
{
13
    public static function map(Traversable $array, Closure $function): array
14
    {
15
        $ret = [];
16
        foreach ($array as $key => $item) {
17
            $ret[$key] = $function($item, $key);
18
        }
19
20
        return $ret;
21
    }
22
23 3
    public static function undot(array $array): array
24
    {
25 3
        $result = [];
26 3
        foreach ($array as $item) {
27
            static::set($result, $item, []);
28
        }
29
30 3
        return $result;
31
    }
32
}
33