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.

ConfigFactory::createFromConfigFile()   B
last analyzed

Complexity

Conditions 3
Paths 4

Size

Total Lines 39
Code Lines 24

Duplication

Lines 0
Ratio 0 %

Importance

Changes 8
Bugs 1 Features 3
Metric Value
c 8
b 1
f 3
dl 0
loc 39
rs 8.8571
cc 3
eloc 24
nc 4
nop 1
1
<?php
2
namespace SeleniumSetup\Config;
3
4
use SeleniumSetup\Binary\Binary;
5
use SeleniumSetup\FileSystem;
6
use SeleniumSetup\SeleniumSetup;
7
8
class ConfigFactory
9
{
10
    public static function createFromConfigFile($configFilePath = null)
11
    {
12
        $fileSystem = new FileSystem();
13
        
14
        if (!$configFilePath) {
15
            $configFilePath = SeleniumSetup::$APP_CONF_PATH . DIRECTORY_SEPARATOR . Config::DEFAULT_CONFIGURATION_FILENAME;
16
        }
17
18
        $configContents = $fileSystem->readFile($configFilePath);
19
        $configObj = json_decode($configContents);
20
        
21
        // @todo: Validate config.
22
        
23
        $config = new Config();
24
25
        // Normalize the paths.
26
        $buildPath = str_replace('{$APP_ROOT_PATH}', SeleniumSetup::$APP_ROOT_PATH, $configObj->buildPath);
27
        $tmpPath = str_replace('{$APP_ROOT_PATH}', SeleniumSetup::$APP_ROOT_PATH, $configObj->tmpPath);
28
        $logsPath = str_replace('{$APP_ROOT_PATH}', SeleniumSetup::$APP_ROOT_PATH, $configObj->logsPath);
29
30
        $config
31
            ->setName($configObj->name)
32
            ->setHostname($configObj->hostname)
33
            ->setPort($configObj->port)
34
            ->setProxyHost($configObj->proxyHost)
35
            ->setProxyPort($configObj->proxyPort)
36
            // Set absolute paths (needed for issuing CLI commands).
37
            ->setBuildPath($buildPath)
38
            ->setTmpPath($tmpPath)
39
            ->setLogsPath($logsPath)
40
            ->setFilePath($configFilePath);
41
42
        foreach ($configObj->binaries as $binaryId => $binaryInfo) {
43
            $binary = Binary::createFromObject($binaryInfo);
44
            $config->setBinary($binaryId, $binary);
45
        }
46
47
        return $config;
48
    }
49
}