Completed
Push — master ( 53e9f8...9de304 )
by Enrico
03:49
created

ConfigurationLoader::load()   A

Complexity

Conditions 2
Paths 3

Size

Total Lines 9
Code Lines 6

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 3
CRAP Score 2.2559

Importance

Changes 0
Metric Value
cc 2
eloc 6
nc 3
nop 2
dl 0
loc 9
ccs 3
cts 5
cp 0.6
crap 2.2559
rs 9.6666
c 0
b 0
f 0
1
<?php
2
/**
3
 * @author Patsura Dmitry https://github.com/ovr <[email protected]>
4
 */
5
6
namespace PHPSA;
7
8
use Symfony\Component\Config\Loader\FileLoader;
9
use Symfony\Component\Yaml\Yaml;
10
11
/**
12
 * Loads configuration from a YAML file
13
 */
14
class ConfigurationLoader extends FileLoader
15
{
16
    /**
17
     * {@inheritdoc}
18
     */
19 1
    public function load($resource, $type = null)
20
    {
21
        try {
22 1
            $path = $this->locator->locate($resource);
23 1
            return Yaml::parse(file_get_contents($path));
24
        } catch (\InvalidArgumentException $e) {
25
            return [];
26
        }
27
    }
28
29
    /**
30
     * {@inheritdoc}
31
     */
32
    public function supports($resource, $type = null)
33
    {
34
        return is_string($resource) && 'yml' === pathinfo($resource, PATHINFO_EXTENSION);
35
    }
36
}
37