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::hasCreateDirectoryIfNotExists()   A

Complexity

Conditions 3
Paths 3

Size

Total Lines 12
Code Lines 5

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 7
CRAP Score 3.0175

Importance

Changes 0
Metric Value
c 0
b 0
f 0
dl 0
loc 12
ccs 7
cts 8
cp 0.875
rs 9.4285
cc 3
eloc 5
nc 3
nop 1
crap 3.0175
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
}