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

Complexity

Total Complexity 3

Size/Duplication

Total Lines 42
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 4

Importance

Changes 13
Bugs 2 Features 4
Metric Value
wmc 3
c 13
b 2
f 4
lcom 0
cbo 4
dl 0
loc 42
rs 10

1 Method

Rating   Name   Duplication   Size   Complexity  
B createFromConfigFile() 0 39 3
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
}