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   A
last analyzed

Complexity

Total Complexity 9

Size/Duplication

Total Lines 32
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 0

Test Coverage

Coverage 100%

Importance

Changes 0
Metric Value
dl 0
loc 32
ccs 19
cts 19
cp 1
rs 10
c 0
b 0
f 0
wmc 9
lcom 0
cbo 0

1 Method

Rating   Name   Duplication   Size   Complexity  
B set() 0 22 9
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
}