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.

ConfigCollectorTrait::getConfig()   A
last analyzed

Complexity

Conditions 5
Paths 5

Size

Total Lines 15
Code Lines 7

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
eloc 7
c 1
b 0
f 0
dl 0
loc 15
rs 9.6111
cc 5
nc 5
nop 2
1
<?php
2
/**
3
 * This file is part of the O2System Framework package.
4
 *
5
 * For the full copyright and license information, please view the LICENSE
6
 * file that was distributed with this source code.
7
 *
8
 * @author         Steeve Andrian Salim
9
 * @copyright      Copyright (c) Steeve Andrian Salim
10
 */
11
12
// ------------------------------------------------------------------------
13
14
namespace O2System\Spl\Traits\Collectors;
15
16
// ------------------------------------------------------------------------
17
use O2System\Kernel\DataStructures\Config;
0 ignored issues
show
Bug introduced by
The type O2System\Kernel\DataStructures\Config was not found. Maybe you did not declare it correctly or list all dependencies?

The issue could also be caused by a filter entry in the build configuration. If the path has been excluded in your configuration, e.g. excluded_paths: ["lib/*"], you can move it to the dependency path list as follows:

filter:
    dependency_paths: ["lib/*"]

For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths

Loading history...
18
19
/**
20
 * Class ConfigCollectorTrait
21
 *
22
 * @package O2System\Spl\Traits\Collectors
23
 */
24
trait ConfigCollectorTrait
25
{
26
    /**
27
     * List of Config
28
     *
29
     * @type array
30
     */
31
    protected $config = [];
32
33
    /**
34
     * Add Config
35
     *
36
     * @param $key
37
     * @param $value
38
     *
39
     * @return $this
40
     */
41
    public function addConfig($key, $value)
42
    {
43
        if (isset($this->config[ $key ])) {
44
            if (is_array($value) AND is_array($this->config[ $key ])) {
45
                $this->config[ $key ] = array_merge($this->config[ $key ], $value);
46
            } else {
47
                $this->config[ $key ] = $value;
48
            }
49
        } else {
50
            $this->config[ $key ] = $value;
51
        }
52
53
        return $this;
54
    }
55
56
    // ------------------------------------------------------------------------
57
58
    /**
59
     * Get Config
60
     *
61
     * @access  public
62
     * @final   this method can't be overwritten
63
     *
64
     * @param string|null $key Config item index name
65
     *
66
     * @return mixed
67
     */
68
    final public function getConfig($key = null, $offset = null)
69
    {
70
        if (isset($key)) {
71
            if (isset($this->config[ $key ])) {
72
                if (isset($offset)) {
73
                    return isset($this->config[ $key ][ $offset ]) ? $this->config[ $key ][ $offset ] : null;
74
                }
75
76
                return $this->config[ $key ];
77
            }
78
79
            return false;
80
        }
81
82
        return $this->config;
83
    }
84
85
    // ------------------------------------------------------------------------
86
87
    /**
88
     * Set Config
89
     *
90
     * @access   public
91
     *
92
     * @param array|string $key
93
     *
94
     * @return static
95
     */
96
    public function setConfig($key, $value = null)
97
    {
98
        if (is_array($key)) {
99
            if (empty($this->config)) {
100
                $this->config = $key;
101
            } else {
102
                $this->config = array_merge($this->config, $key);
103
            }
104
        } elseif ($key instanceof Config) {
0 ignored issues
show
introduced by
$key is never a sub-type of O2System\Kernel\DataStructures\Config.
Loading history...
105
            $this->config = $key;
106
        } elseif (isset($this->config[ $key ])) {
107
            if (is_array($value) AND is_array($this->config[ $key ])) {
108
                $this->config[ $key ] = array_merge($this->config[ $key ], $value);
109
            } else {
110
                $this->config[ $key ] = $value;
111
            }
112
        } else {
113
            $this->config[ $key ] = $value;
114
        }
115
116
        return $this;
117
    }
118
}