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 ( 86dce3...98cf71 )
by Nur
02:40
created

Config::addItem()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 3
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 1
eloc 1
nc 1
nop 2
dl 0
loc 3
rs 10
c 0
b 0
f 0
1
<?php
2
/**
3
 * This file is part of the O2System PHP 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\Reactor\Services;
15
16
// ------------------------------------------------------------------------
17
18
use O2System\Kernel\Containers\Environment;
19
use O2System\Spl\Datastructures\SplArrayObject;
20
21
/**
22
 * Class Config
23
 *
24
 * @package O2System\Reactor\Services
25
 */
26
class Config extends Environment
27
{
28
    /**
29
     * Config::loadFile
30
     *
31
     * @param string $offset
32
     * @param bool   $return
33
     *
34
     * @return mixed
35
     */
36
    public function loadFile($offset, $return = false)
37
    {
38
        $basename = pathinfo($offset, PATHINFO_BASENAME);
39
        $filename = studlycase($basename);
40
41
        $configFile = str_replace($basename, $filename, $offset);
42
        $offset = camelcase($basename);
43
44
        $configDirs = [
45
            PATH_FRAMEWORK . 'Config' . DIRECTORY_SEPARATOR,
46
            PATH_APP . 'Config' . DIRECTORY_SEPARATOR,
47
        ];
48
49
        if (method_exists(modules(), 'getDirs')) {
0 ignored issues
show
Bug introduced by
The function modules was not found. Maybe you did not declare it correctly or list all dependencies? ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-call  annotation

49
        if (method_exists(/** @scrutinizer ignore-call */ modules(), 'getDirs')) {
Loading history...
50
            $configDirs = modules()->getDirs('Config', true);
51
        }
52
53
        foreach ($configDirs as $configDir) {
54
            if (is_file(
55
                $filePath = $configDir . ucfirst(
56
                        strtolower(ENVIRONMENT)
0 ignored issues
show
Bug introduced by
The constant O2System\Reactor\Services\ENVIRONMENT was not found. Maybe you did not declare it correctly or list all dependencies?
Loading history...
57
                    ) . DIRECTORY_SEPARATOR . $configFile . '.php'
58
            )) {
59
                include($filePath);
60
            } elseif (is_file($filePath = $configDir . DIRECTORY_SEPARATOR . $configFile . '.php')) {
61
                include($filePath);
62
            }
63
        }
64
65
        if (isset($$offset)) {
66
            $this->addItem($offset, $$offset);
67
68
            unset($$offset);
69
70
            if ($return) {
71
                return $this->getItem($offset);
72
            }
73
74
            return true;
75
        }
76
77
        return false;
78
    }
79
80
    // ------------------------------------------------------------------------
81
82
    /**
83
     * Config::addItem
84
     *
85
     * Adds config item.
86
     *
87
     * @param string $offset
88
     * @param mixed  $value
89
     */
90
    public function addItem($offset, $value)
91
    {
92
        $this->offsetSet($offset, $value);
93
    }
94
95
    // ------------------------------------------------------------------------
96
97
    /**
98
     * Config::getItem
99
     *
100
     * Gets config item.
101
     *
102
     * @param string $offset
103
     *
104
     * @return mixed|\O2System\Spl\Datastructures\SplArrayObject
105
     */
106
    public function &getItem($offset)
107
    {
108
        $item = parent::offsetGet($offset);
109
110
        if (is_array($item)) {
111
            if (is_string(key($item))) {
112
                $item = new SplArrayObject($item);
113
            }
114
        }
115
116
        return $item;
117
    }
118
119
    // ------------------------------------------------------------------------
120
121
    /**
122
     * Config::setItem
123
     *
124
     * Sets config item.
125
     *
126
     * @param string $offset
127
     * @param mixed  $value
128
     */
129
    public function setItem($offset, $value)
130
    {
131
        $this->offsetSet($offset, $value);
132
    }
133
}