Passed
Push — master ( c38e78...642601 )
by Stephen
50s queued 12s
created

ArrayHelpers::removeKeys()   A

Complexity

Conditions 3
Paths 3

Size

Total Lines 10
Code Lines 5

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 3
eloc 5
nc 3
nop 1
dl 0
loc 10
rs 10
c 0
b 0
f 0
1
<?php
2
3
namespace Sfneal\Helpers\Arrays;
4
5
use Sfneal\Helpers\Arrays\Utils\ArrayUtility;
6
7
class ArrayHelpers
8
{
9
    /**
10
     * Instantiate a `ArrayUtility` instance by passing an $array to the constructor.
11
     *
12
     * @param array $array
13
     * @return ArrayUtility
14
     */
15
    public static function from(array $array): ArrayUtility
16
    {
17
        return new ArrayUtility($array);
18
    }
19
20
    /**
21
     * Sum the values of two arrays.
22
     *
23
     * @param array $array1
24
     * @param array $array2
25
     * @return array
26
     */
27
    public static function sum(array $array1, array $array2): array
28
    {
29
        // todo: add ability to pass array of arrays
30
        $array = [];
31
        foreach ($array1 as $index => $value) {
32
            $array[$index] = isset($array2[$index]) ? $array2[$index] + $value : $value;
33
        }
34
35
        return $array;
36
    }
37
}
38