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

Arr   A

Complexity

Total Complexity 4

Size/Duplication

Total Lines 22
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 1

Test Coverage

Coverage 40%

Importance

Changes 0
Metric Value
dl 0
loc 22
ccs 4
cts 10
cp 0.4
rs 10
c 0
b 0
f 0
wmc 4
lcom 0
cbo 1

2 Methods

Rating   Name   Duplication   Size   Complexity  
A map() 0 9 2
A undot() 0 9 2
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