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.
Test Setup Failed
Push — master ( 20f039...a7e888 )
by Carlos
02:05
created

Config::__construct()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 3
CRAP Score 1

Importance

Changes 0
Metric Value
dl 0
loc 4
ccs 3
cts 3
cp 1
rs 10
c 0
b 0
f 0
cc 1
eloc 2
nc 1
nop 1
crap 1
1
<?php
2
3
/*
4
 * This file is part of the overtrue/easy-sms.
5
 *
6
 * (c) overtrue <[email protected]>
7
 *
8
 * This source file is subject to the MIT license that is bundled
9
 * with this source code in the file LICENSE.
10
 */
11
12
namespace Overtrue\EasySms\Support;
13
14
use ArrayAccess;
15
16
/**
17
 * Class Config.
18
 */
19
class Config implements ArrayAccess
20
{
21
    /**
22
     * @var array
23
     */
24
    protected $config;
25
26
    /**
27
     * Config constructor.
28
     *
29
     * @param array $config
30
     */
31 35
    public function __construct(array $config = [])
32
    {
33 35
        $this->config = $config;
34 35
    }
35
36
    /**
37
     * Get an item from an array using "dot" notation.
38
     *
39
     * @param string $key
40
     * @param mixed  $default
41
     *
42
     * @return mixed
43
     */
44 19
    public function get($key, $default = null)
45
    {
46 19
        $config = $this->config;
47
48 19
        if (is_null($key)) {
49 1
            return null;
50
        }
51
52 19
        if (isset($config[$key])) {
53 16
            return $config[$key];
54
        }
55
        
56 7
        if (strpos($key, '.') === false) {
57 7
            return $default;
58 7
        }
59
60 1
        foreach (explode('.', $key) as $segment) {
61 1
            if (!is_array($config) || !array_key_exists($segment, $config)) {
62
                return $default;
63 1
            }
64
            $config = $config[$segment];
65
        }
66
67
        return $config;
68
    }
69
70
    /**
71
     * Whether a offset exists.
72
     *
73
     * @see  http://php.net/manual/en/arrayaccess.offsetexists.php
74
     *
75
     * @param mixed $offset <p>
76
     *                      An offset to check for.
77
     *                      </p>
78
     *
79
     * @return bool true on success or false on failure.
80
     *              </p>
81
     *              <p>
82 1
     *              The return value will be casted to boolean if non-boolean was returned
83
     *
84 1
     * @since 5.0.0
85
     */
86
    public function offsetExists($offset)
87
    {
88
        return array_key_exists($offset, $this->config);
89
    }
90
91
    /**
92
     * Offset to retrieve.
93
     *
94
     * @see  http://php.net/manual/en/arrayaccess.offsetget.php
95
     *
96
     * @param mixed $offset <p>
97
     *                      The offset to retrieve.
98
     *                      </p>
99
     *
100 1
     * @return mixed Can return all value types
101
     *
102 1
     * @since 5.0.0
103
     */
104
    public function offsetGet($offset)
105
    {
106
        return $this->get($offset);
107
    }
108
109
    /**
110
     * Offset to set.
111
     *
112
     * @see  http://php.net/manual/en/arrayaccess.offsetset.php
113
     *
114
     * @param mixed $offset <p>
115
     *                      The offset to assign the value to.
116
     *                      </p>
117
     * @param mixed $value  <p>
118
     *                      The value to set.
119 1
     *                      </p>
120
     *
121 1
     * @since 5.0.0
122 1
     */
123 1
    public function offsetSet($offset, $value)
124 1
    {
125
        if (isset($this->config[$offset])) {
126
            $this->config[$offset] = $value;
127
        }
128
    }
129
130
    /**
131
     * Offset to unset.
132
     *
133
     * @see  http://php.net/manual/en/arrayaccess.offsetunset.php
134
     *
135
     * @param mixed $offset <p>
136
     *                      The offset to unset.
137 1
     *                      </p>
138
     *
139 1
     * @since 5.0.0
140 1
     */
141 1
    public function offsetUnset($offset)
142 1
    {
143
        if (isset($this->config[$offset])) {
144
            unset($this->config[$offset]);
145
        }
146
    }
147
}
148