GitHub Access Token became invalid

It seems like the GitHub access token used for retrieving details about this repository from GitHub became invalid. This might prevent certain types of inspections from being run (in particular, everything related to pull requests).
Please ask an admin of your repository to re-new the access token on this website.

ArrayHelper::set()   B
last analyzed

Complexity

Conditions 9
Paths 39

Size

Total Lines 22

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 19
CRAP Score 9

Importance

Changes 0
Metric Value
cc 9
nc 39
nop 3
dl 0
loc 22
ccs 19
cts 19
cp 1
crap 9
rs 8.0555
c 0
b 0
f 0
1
<?php
2
namespace PhpBoot\Utils;
3
4
class ArrayHelper
5
{
6
    /**
7
     * TODO 支持""转意
8
     * @param array|\ArrayAccess $arr
9
     * @param string $key like key1.key2.key3
10
     * @param mixed $val
11
     */
12 7
    static public function set(&$arr, $key, $val)
13
    {
14 7
        $arr instanceof \ArrayAccess || is_array($arr) or \PhpBoot\abort(new \InvalidArgumentException('the first param require array or object of ArrayAccess'));
15 7
        $keys = explode('.', $key);
16 7
        $keys = array_reverse($keys);
17 7
        $cur = &$arr;
18 7
        while($p = array_pop($keys)){
19 7
            $cur instanceof \ArrayAccess || is_array($cur) or \PhpBoot\abort(new \InvalidArgumentException('array or object of ArrayAccess required'));
20 7
            if(!isset($cur[$p])){
21 7
                if(count($keys) == 0){
22 7
                    $cur[$p] = $val;
23 7
                }else{
24 6
                    $cur[$p] = [];
25
                }
26 7
            }else{
27 6
                if(count($keys) == 0){
28 1
                    $cur[$p] = $val;
29 1
                }
30
            }
31 7
            $cur = &$cur[$p];
32 7
        }
33 7
    }
34
35
}