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   A

Complexity

Total Complexity 4

Size/Duplication

Total Lines 48
Duplicated Lines 0 %

Test Coverage

Coverage 100%

Importance

Changes 1
Bugs 0 Features 0
Metric Value
eloc 11
c 1
b 0
f 0
dl 0
loc 48
ccs 13
cts 13
cp 1
rs 10
wmc 4

3 Methods

Rating   Name   Duplication   Size   Complexity  
A set() 0 5 1
A getConfigManager() 0 7 2
A get() 0 6 1
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