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 ( a1835d...10e84a )
by
unknown
02:48
created

Config   A

Complexity

Total Complexity 12

Size/Duplication

Total Lines 106
Duplicated Lines 0 %

Importance

Changes 0
Metric Value
eloc 33
dl 0
loc 106
rs 10
c 0
b 0
f 0
wmc 12

4 Methods

Rating   Name   Duplication   Size   Complexity  
A setItem() 0 3 1
B loadFile() 0 42 7
A getItem() 0 11 3
A addItem() 0 3 1
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\Framework\Containers;
15
16
// ------------------------------------------------------------------------
17
18
use O2System\Spl\DataStructures\SplArrayObject;
19
20
/**
21
 * Class Config
22
 *
23
 * @package O2System\Framework\Containers
24
 */
25
class Config extends Environment
26
{
27
    /**
28
     * Config::loadFile
29
     *
30
     * @param string $offset
31
     * @param bool   $return
32
     *
33
     * @return mixed
34
     */
35
    public function loadFile($offset, $return = false)
36
    {
37
        $basename = pathinfo($offset, PATHINFO_BASENAME);
38
        $filename = studlycase($basename);
39
40
        $configFile = str_replace($basename, $filename, $offset);
41
        $offset = camelcase($basename);
42
43
        $configDirs = [
44
            PATH_FRAMEWORK . 'Config' . DIRECTORY_SEPARATOR,
45
            PATH_APP . 'Config' . DIRECTORY_SEPARATOR,
46
        ];
47
48
        if(null !== o2system()->modules) {
49
            $configDirs = modules()->getDirs('Config', true);
0 ignored issues
show
Bug introduced by
The method getDirs() does not exist on O2System\Framework\Conta...s\DataStructures\Module. Did you maybe mean getDir()? ( Ignorable by Annotation )

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

49
            $configDirs = modules()->/** @scrutinizer ignore-call */ getDirs('Config', true);

This check looks for calls to methods that do not seem to exist on a given type. It looks for the method on the type itself as well as in inherited classes or implemented interfaces.

This is most likely a typographical error or the method has been renamed.

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