Test Failed
Push — master ( c28bb2...68d0c2 )
by Julien
11:50
created

array_search_key_recursive()   A

Complexity

Conditions 4
Paths 4

Size

Total Lines 11
Code Lines 6

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 0
CRAP Score 20

Importance

Changes 1
Bugs 0 Features 0
Metric Value
cc 4
eloc 6
c 1
b 0
f 0
nc 4
nop 3
dl 0
loc 11
ccs 0
cts 6
cp 0
crap 20
rs 10
1
<?php
2
3
if (!function_exists('array_unset_recursive')) {
4
    
5
    function array_unset_recursive(array &$array, array $keyList, bool $strict = true): int
6
    {
7
        $removeCount = 0;
8
        foreach ($array as $key => $element) {
9
            if (in_array($key, $keyList, $strict)) {
10
                unset($array[$key]);
11
                $removeCount++;
12
            }
13
            elseif (is_array($element)) {
14
                array_unset_recursive($array[$key], $keyList, $strict);
15
            }
16
        }
17
        return $removeCount;
18
    }
19
}
20