Completed
Push — master ( b1b3d7...ed93a7 )
by Дмитрий
03:53
created

ConfigurationLoader   A

Complexity

Total Complexity 4

Size/Duplication

Total Lines 18
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 3

Test Coverage

Coverage 0%

Importance

Changes 1
Bugs 0 Features 0
Metric Value
c 1
b 0
f 0
dl 0
loc 18
ccs 0
cts 7
cp 0
rs 10
wmc 4
lcom 1
cbo 3

2 Methods

Rating   Name   Duplication   Size   Complexity  
A load() 0 10 2
A supports() 0 4 2
1
<?php
2
/**
3
 * @author Patsura Dmitry https://github.com/ovr <[email protected]>
4
 */
5
6
7
namespace PHPSA;
8
9
use Symfony\Component\Config\Loader\FileLoader;
10
use Symfony\Component\Yaml\Yaml;
11
12
class ConfigurationLoader extends FileLoader
13
{
14
    public function load($resource, $type = null)
15
    {
16
        try {
17
            $config = $this->locator->locate($resource);
0 ignored issues
show
Unused Code introduced by
$config 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...
18
        } catch (\InvalidArgumentException $e) {
19
            return [];
20
        }
21
22
        return Yaml::parse(file_get_contents($resource));
23
    }
24
25
    public function supports($resource, $type = null)
26
    {
27
        return is_string($resource) && 'yml' === pathinfo($resource, PATHINFO_EXTENSION);
28
    }
29
}
30