Passed
Push — master ( d2ad69...686350 )
by Kacper
02:44
created

ArrayHelper   A

Complexity

Total Complexity 5

Size/Duplication

Total Lines 25
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 0

Test Coverage

Coverage 100%

Importance

Changes 7
Bugs 0 Features 0
Metric Value
wmc 5
c 7
b 0
f 0
lcom 0
cbo 0
dl 0
loc 25
ccs 9
cts 9
cp 1
rs 10

3 Methods

Rating   Name   Duplication   Size   Complexity  
A rearrange() 0 6 1
A column() 0 4 1
A find() 0 10 3
1
<?php
2
/**
3
 * Highlighter
4
 *1
5
 * Copyright (C) 2015, Some right reserved.
6
 *
7
 * @author Kacper "Kadet" Donat <[email protected]>
8
 *
9
 * Contact with author:
10
 * Xmpp: [email protected]
11
 * E-mail: [email protected]
12
 *
13
 * From Kadet with love.
14
 */
15
16
namespace Kadet\Highlighter\Utils;
17
18
19
class ArrayHelper
20
{
21 1
    public static function rearrange(array $array, array $keys)
22
    {
23
        return array_combine($keys, array_map(function ($key) use ($array) {
24 1
            return $array[$key];
25 1
        }, $keys));
26
    }
27
28
    public static function column(array $array, $index)
29
    {
30
        return array_map(function ($e) use ($index) { return $e[$index]; }, $array);
31
    }
32
33 1
    public static function find(array $array, callable $tester)
34
    {
35 1
        foreach ($array as $key => $value) {
36 1
            if ($tester($key, $value)) {
37 1
                return $key;
38
            }
39 1
        }
40
41 1
        return false;
42
    }
43
}