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.

CommandUtils::getOsHomeDir()   A
last analyzed

Complexity

Conditions 4
Paths 4

Size

Total Lines 18
Code Lines 10

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 8
CRAP Score 4.128

Importance

Changes 0
Metric Value
c 0
b 0
f 0
dl 0
loc 18
ccs 8
cts 10
cp 0.8
rs 9.2
cc 4
eloc 10
nc 4
nop 0
crap 4.128
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
class CommandUtils implements CommandUtilsInterface
14
{
15
    /**
16
     * @link   https://github.com/composer/composer/blob/69210d5bc130f8cc9f96f99582a041254d7b9833/src/Composer/Factory.php
17
     * @return string
18
     */
19 3
    public static function getOsHomeDir()
20
    {
21 3
        if (defined('PHP_WINDOWS_VERSION_MAJOR')) {
22 1
            if (!getenv('APPDATA')) {
23
                throw new \RuntimeException('The APPDATA or CHAPI_HOME environment variable must be set for composer to run correctly');
24
            }
25 1
            return  rtrim(
26 1
                strtr(getenv('APPDATA'), '\\', '/'),
27 1
                '/'
28
            );
29
        }
30
31
        // else
32 2
        if (!getenv('HOME')) {
33
            throw new \RuntimeException('The HOME or CHAPI_HOME environment variable must be set for composer to run correctly');
34
        }
35 2
        return rtrim(getenv('HOME'), '/');
36
    }
37
38
    /**
39
     * @param string $dir
40
     * @return bool
41
     */
42 3
    public static function hasCreateDirectoryIfNotExists($dir)
43
    {
44 3
        if (!is_dir($dir)) {
45 2
            if (!mkdir($dir, 0755, true)) {
46
                throw new \RuntimeException(sprintf('Unable to create cache directory "%s"', $dir));
47
            }
48
        }
49
50 3
        return true;
51
    }
52
}
53