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.
Passed
Push — master ( 92da26...0aebbe )
by TJ
02:12
created

Arr::accessible()   A

Complexity

Conditions 2
Paths 2

Size

Total Lines 3
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 2
eloc 1
nc 2
nop 1
dl 0
loc 3
rs 10
c 0
b 0
f 0
1
<?php
2
3
namespace Honeybadger\Support;
4
5
class Arr
6
{
7
    /**
8
     * Determine whether the given value is array accessible.
9
     *
10
     * @param  mixed  $value
11
     * @return bool
12
     */
13
    public static function accessible($value)
14
    {
15
        return is_array($value) || $value instanceof \ArrayAccess;
16
    }
17
18
    /**
19
     * Get an item from an array using "dot" notation.
20
     *
21
     * @param  \ArrayAccess|array  $array
22
     * @param  string  $key
23
     * @param  mixed   $default
24
     * @return mixed
25
     */
26
    public static function get($array, $key, $default = null)
27
    {
28
        if (! static::accessible($array)) {
29
            return $default;
30
        }
31
32
        if (static::exists($array, $key)) {
33
            return $array[$key];
34
        }
35
36
        if (strpos($key, '.') === false) {
37
            return $array[$key] ?? $default;
38
        }
39
40
        foreach (explode('.', $key) as $segment) {
41
            if (static::accessible($array) && static::exists($array, $segment)) {
42
                $array = $array[$segment];
43
            } else {
44
                return $default;
45
            }
46
        }
47
48
        return $array;
49
    }
50
51
    /**
52
     * Determine if the given key exists in the provided array.
53
     *
54
     * @param  \ArrayAccess|array  $array
55
     * @param  string|int  $key
56
     * @return bool
57
     */
58
    public static function exists($array, $key)
59
    {
60
        if ($array instanceof \ArrayAccess) {
61
            return $array->offsetExists($key);
62
        }
63
64
        return array_key_exists($key, $array);
65
    }
66
67
    /**
68
     * @param  array  $array
69
     * @param  callable  $callback
70
     * @return array
71
     */
72
    public static function mapWithKeys(array $array, callable $callback) : array
73
    {
74
        $newArray = [];
75
76
        foreach ($array as $key => $item) {
77
            $newArray[$key] = $callback($item, $key);
78
        }
79
80
        return $newArray;
81
    }
82
}
83