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

Complexity

Conditions 3
Paths 3

Size

Total Lines 10
Code Lines 5

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 4
CRAP Score 3.072

Importance

Changes 0
Metric Value
dl 0
loc 10
ccs 4
cts 5
cp 0.8
rs 9.4285
c 0
b 0
f 0
cc 3
eloc 5
nc 3
nop 1
crap 3.072
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