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   A
last analyzed

Complexity

Total Complexity 7

Size/Duplication

Total Lines 47
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 3

Test Coverage

Coverage 38.1%

Importance

Changes 4
Bugs 2 Features 0
Metric Value
wmc 7
c 4
b 2
f 0
lcom 0
cbo 3
dl 0
loc 47
ccs 8
cts 21
cp 0.381
rs 10

2 Methods

Rating   Name   Duplication   Size   Complexity  
B getHomeDir() 0 19 5
A createConfig() 0 14 2
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