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

Complexity

Total Complexity 7

Size/Duplication

Total Lines 40
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 0

Test Coverage

Coverage 80%

Importance

Changes 0
Metric Value
wmc 7
lcom 0
cbo 0
dl 0
loc 40
ccs 12
cts 15
cp 0.8
rs 10
c 0
b 0
f 0

2 Methods

Rating   Name   Duplication   Size   Complexity  
A getOsHomeDir() 0 18 4
A hasCreateDirectoryIfNotExists() 0 10 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
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