Completed
Push — master ( 6fb51e...94364b )
by Thierry
01:40
created

Reader   A

Complexity

Total Complexity 5

Size/Duplication

Total Lines 28
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 4

Importance

Changes 0
Metric Value
dl 0
loc 28
rs 10
c 0
b 0
f 0
wmc 5
lcom 0
cbo 4

1 Method

Rating   Name   Duplication   Size   Complexity  
A read() 0 18 5
1
<?php
2
3
/**
4
 * Reader.php - Jaxon config reader
5
 *
6
 * @package jaxon-core
7
 * @author Thierry Feuzeu <[email protected]>
8
 * @copyright 2016 Thierry Feuzeu <[email protected]>
9
 * @license https://opensource.org/licenses/BSD-3-Clause BSD 3-Clause License
10
 * @link https://github.com/jaxon-php/jaxon-core
11
 */
12
13
namespace Jaxon\Config;
14
15
class Reader
16
{
17
    /**
18
     * Read options from a config file
19
     *
20
     * @param string        $sConfigFile        The full path to the config file
21
     *
22
     * @return array
23
     */
24
    public function read($sConfigFile)
25
    {
26
        $sExt = pathinfo($sConfigFile, PATHINFO_EXTENSION);
27
        switch($sExt)
28
        {
29
        case 'php':
30
            $aConfigOptions = Php::read($sConfigFile);
0 ignored issues
show
Unused Code introduced by
$aConfigOptions is not used, you could remove the assignment.

This check looks for variable assignements that are either overwritten by other assignments or where the variable is not used subsequently.

$myVar = 'Value';
$higher = false;

if (rand(1, 6) > 3) {
    $higher = true;
} else {
    $higher = false;
}

Both the $myVar assignment in line 1 and the $higher assignment in line 2 are dead. The first because $myVar is never used and the second because $higher is always overwritten for every possible time line.

Loading history...
31
        case 'yaml':
32
        case 'yml':
33
            $aConfigOptions = Yaml::read($sConfigFile);
0 ignored issues
show
Unused Code introduced by
$aConfigOptions is not used, you could remove the assignment.

This check looks for variable assignements that are either overwritten by other assignments or where the variable is not used subsequently.

$myVar = 'Value';
$higher = false;

if (rand(1, 6) > 3) {
    $higher = true;
} else {
    $higher = false;
}

Both the $myVar assignment in line 1 and the $higher assignment in line 2 are dead. The first because $myVar is never used and the second because $higher is always overwritten for every possible time line.

Loading history...
34
        case 'json':
35
            $aConfigOptions = Json::read($sConfigFile);
0 ignored issues
show
Unused Code introduced by
$aConfigOptions is not used, you could remove the assignment.

This check looks for variable assignements that are either overwritten by other assignments or where the variable is not used subsequently.

$myVar = 'Value';
$higher = false;

if (rand(1, 6) > 3) {
    $higher = true;
} else {
    $higher = false;
}

Both the $myVar assignment in line 1 and the $higher assignment in line 2 are dead. The first because $myVar is never used and the second because $higher is always overwritten for every possible time line.

Loading history...
36
        default:
37
            $sErrorMsg = jaxon_trans('config.errors.file.extension', array('path' => $sConfigFile));
38
            throw new \Jaxon\Config\Exception\File($sErrorMsg);
39
        }
40
        return $aConfigOptions;
0 ignored issues
show
Unused Code introduced by
return $aConfigOptions; does not seem to be reachable.

This check looks for unreachable code. It uses sophisticated control flow analysis techniques to find statements which will never be executed.

Unreachable code is most often the result of return, die or exit statements that have been added for debug purposes.

function fx() {
    try {
        doSomething();
        return true;
    }
    catch (\Exception $e) {
        return false;
    }

    return false;
}

In the above example, the last return false will never be executed, because a return statement has already been met in every possible execution path.

Loading history...
41
    }
42
}
43