Completed
Pull Request — master (#283)
by Enrico
04:27
created

ConfigurationLoader::load()   A

Complexity

Conditions 2
Paths 2

Size

Total Lines 10
Code Lines 6

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 4
CRAP Score 2.032

Importance

Changes 0
Metric Value
cc 2
eloc 6
nc 2
nop 2
dl 0
loc 10
ccs 4
cts 5
cp 0.8
crap 2.032
rs 9.4285
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
            $this->locator->locate($resource);
23 1
        } catch (\InvalidArgumentException $e) {
24
            return [];
25
        }
26
27 1
        return Yaml::parse(file_get_contents($resource));
28
    }
29
30
    /**
31
     * {@inheritdoc}
32
     */
33
    public function supports($resource, $type = null)
34
    {
35
        return is_string($resource) && 'yml' === pathinfo($resource, PATHINFO_EXTENSION);
36
    }
37
}
38