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.

Config::get()   A
last analyzed

Complexity

Conditions 3
Paths 3

Size

Total Lines 18
Code Lines 10

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 1 Features 0
Metric Value
c 1
b 1
f 0
dl 0
loc 18
rs 9.4285
cc 3
eloc 10
nc 3
nop 2
1
<?php namespace Xaoc303\BattleCalc;
2
3
class Config
4
{
5
    public static function get($key, $default = null)
6
    {
7
        if (empty($key)) {
8
            return $default;
9
        }
10
11
        $key = str_replace("battle-calc::", "", $key);
12
        $keys = explode('.', $key);
13
14
        $pathToDirConfigs = self::getPathToDirConfigs();
15
        $fullPathToFileConfig = self::getPathToFileConfig($pathToDirConfigs, $keys);
16
17
        if (!file_exists( $fullPathToFileConfig )) {
18
            return $default;
19
        }
20
21
        return self::getArrayFromFile($fullPathToFileConfig, $keys);
22
    }
23
24
    private static function getPathToDirConfigs()
25
    {
26
        return __DIR__ . DIRECTORY_SEPARATOR . '..' . DIRECTORY_SEPARATOR . '..' . DIRECTORY_SEPARATOR . 'config' . DIRECTORY_SEPARATOR;
27
    }
28
29
    private static function getPathToFileConfig($pathToDirConfigs, $keys)
30
    {
31
        return $pathToDirConfigs. $keys[0]. '.php';
32
    }
33
34
    private static function getArrayFromFile($file, $keys)
35
    {
36
        $get = function() use ($file) {
37
            return include $file;
38
        };
39
        $return = $get();
40
        unset($keys[0]);
41
42
        foreach ($keys as $v) {
43
            if (isset($return[$v])) {
44
                $return = $return[$v];
45
            }
46
        }
47
        return $return;
48
    }
49
}