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
Pull Request — master (#231)
by Yong
11:24
created

Config::getConfigManager()   A

Complexity

Conditions 2
Paths 2

Size

Total Lines 7
Code Lines 3

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 5
CRAP Score 2

Importance

Changes 0
Metric Value
cc 2
eloc 3
c 0
b 0
f 0
nc 2
nop 0
dl 0
loc 7
ccs 5
cts 5
cp 1
crap 2
rs 10
1
<?php
2
3
namespace AlibabaCloud\Client\Config;
4
5
use Exception;
6
use clagiordano\weblibs\configmanager\ConfigManager;
7
8
/**
9
 * Class Config
10
 *
11
 * @package   AlibabaCloud\Client\Config
12
 */
13
class Config
14
{
15
16
    /**
17
     * @var ConfigManager|null
18
     */
19
    private static $configManager;
20
21
    /**
22
     * @param string      $configPath
23
     *
24
     * @param string|null $defaultValue
25
     *
26
     * @return mixed
27
     */
28 55
    public static function get($configPath, $defaultValue = null)
29
    {
30 55
        return self::getConfigManager()
31 55
                   ->getValue(
32 55
                       \strtolower($configPath),
33
                       $defaultValue
34 55
                   );
35
    }
36
37
    /**
38
     * @return ConfigManager
39
     */
40 56
    private static function getConfigManager()
41
    {
42 56
        if (!self::$configManager instanceof ConfigManager) {
43 2
            self::$configManager = new ConfigManager(__DIR__ . DIRECTORY_SEPARATOR . 'Data.php');
44 2
        }
45
46 56
        return self::$configManager;
47
    }
48
49
    /**
50
     * @param string $configPath
51
     * @param mixed  $newValue
52
     *
53
     * @return ConfigManager
54
     * @throws Exception
55
     */
56 1
    public static function set($configPath, $newValue)
57
    {
58 1
        self::getConfigManager()->setValue(\strtolower($configPath), $newValue);
59
60 1
        return self::getConfigManager()->saveConfigFile();
61
    }
62
}
63