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

ConfigurationLoader::supports()   A

Complexity

Conditions 2
Paths 2

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 0
CRAP Score 6

Importance

Changes 0
Metric Value
cc 2
eloc 2
nc 2
nop 2
dl 0
loc 4
ccs 0
cts 2
cp 0
crap 6
rs 10
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