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.

Arr   A
last analyzed

Complexity

Total Complexity 14

Size/Duplication

Total Lines 81
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 0

Importance

Changes 0
Metric Value
wmc 14
lcom 1
cbo 0
dl 0
loc 81
rs 10
c 0
b 0
f 0

4 Methods

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