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.
Completed
Pull Request — master (#68)
by Bidesh
03:32
created

CommandUtils   A

Complexity

Total Complexity 7

Size/Duplication

Total Lines 45
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 0

Test Coverage

Coverage 85.71%

Importance

Changes 0
Metric Value
wmc 7
c 0
b 0
f 0
lcom 0
cbo 0
dl 0
loc 45
ccs 18
cts 21
cp 0.8571
rs 10

2 Methods

Rating   Name   Duplication   Size   Complexity  
A getOsHomeDir() 0 21 4
A hasCreateDirectoryIfNotExists() 0 12 3
1
<?php
2
/**
3
 * @package: chapi
4
 *
5
 * @author:  msiebeneicher
6
 * @since:   2015-09-20
7
 *
8
 */
9
10
11
namespace Chapi\Component\Command;
12
13
14
class CommandUtils implements CommandUtilsInterface
15
{
16
    /**
17
     * @link   https://github.com/composer/composer/blob/69210d5bc130f8cc9f96f99582a041254d7b9833/src/Composer/Factory.php
18
     * @return string
19
     */
20 3
    public static function getOsHomeDir()
21
    {
22 3
        if (defined('PHP_WINDOWS_VERSION_MAJOR'))
23 3
        {
24 1
            if (!getenv('APPDATA'))
25 1
            {
26
                throw new \RuntimeException('The APPDATA or CHAPI_HOME environment variable must be set for composer to run correctly');
27
            }
28 1
            return  rtrim(
29 1
                strtr(getenv('APPDATA'), '\\', '/'),
30
                '/'
31 1
            );
32
        }
33
34
        // else
35 2
        if (!getenv('HOME'))
36 2
        {
37
            throw new \RuntimeException('The HOME or CHAPI_HOME environment variable must be set for composer to run correctly');
38
        }
39 2
        return rtrim(getenv('HOME'), '/');
40
    }
41
42
    /**
43
     * @param string $sDir
44
     * @return bool
45
     */
46 3
    public static function hasCreateDirectoryIfNotExists($sDir)
47
    {
48 3
        if (!is_dir($sDir))
49 3
        {
50 2
            if (!mkdir($sDir, 0755, true))
51 2
            {
52
                throw new \RuntimeException(sprintf('Unable to create cache directory "%s"', $sDir));
53
            }
54 2
        }
55
56 3
        return true;
57
    }
58
}