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.

ConfigFactory::getHomeDir()   B
last analyzed

Complexity

Conditions 5
Paths 5

Size

Total Lines 19
Code Lines 12

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 0
CRAP Score 30

Importance

Changes 1
Bugs 0 Features 0
Metric Value
c 1
b 0
f 0
dl 0
loc 19
ccs 0
cts 13
cp 0
rs 8.8571
cc 5
eloc 12
nc 5
nop 0
crap 30
1
<?php
2
3
/*
4
 * This file is part of the slack-cli package.
5
 *
6
 * (c) Cas Leentfaar <[email protected]>
7
 *
8
 * For the full copyright and license information, please view the LICENSE
9
 * file that was distributed with this source code.
10
 */
11
12
namespace CL\SlackCli\Config;
13
14
use Composer\Config\JsonConfigSource;
15
use Composer\Json\JsonFile;
16
17
/**
18
 * @author Ryan Weaver <[email protected]>
19
 * @author Jordi Boggiano <[email protected]>
20
 * @author Igor Wiedler <[email protected]>
21
 * @author Nils Adermann <[email protected]>
22
 * @author Cas Leentfaar <[email protected]>
23
 */
24
class ConfigFactory
25
{
26
    /**
27
     * @return string
28
     *
29
     * @throws \RuntimeException
30
     */
31
    public static function getHomeDir()
32
    {
33
        $home = getenv('SLACK_CLI_HOME');
34
        if (!$home) {
35
            if (defined('PHP_WINDOWS_VERSION_MAJOR')) {
36
                if (!getenv('APPDATA')) {
37
                    throw new \RuntimeException('The APPDATA or SLACK_CLI_HOME environment variable must be set for Slack CLI to run correctly');
38
                }
39
                $home = strtr(getenv('APPDATA'), '\\', '/') . '/SlackCli';
40
            } else {
41
                if (!getenv('HOME')) {
42
                    throw new \RuntimeException('The HOME or SLACK_CLI_HOME environment variable must be set for Slack CLI to run correctly');
43
                }
44
                $home = rtrim(getenv('HOME'), '/') . '/.slack-cli';
45
            }
46
        }
47
48
        return $home;
49
    }
50
51
    /**
52
     * @param string $path
53
     *
54
     * @return Config
55
     */
56 5
    public static function createConfig($path)
57
    {
58 5
        $config = new Config();
59
60
        // load global config
61 5
        $file = new JsonFile($path);
62 5
        if ($file->exists()) {
63 4
            $config->merge($file->read());
64 4
        }
65
        
66 5
        $config->setConfigSource(new JsonConfigSource($file));
67
68 5
        return $config;
69
    }
70
}
71