YamlConfigDriver::supports()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
c 1
b 0
f 0
dl 0
loc 4
rs 10
cc 1
eloc 2
nc 1
nop 1
1
<?php
2
3
namespace Igorw\Silex;
4
5
use Symfony\Component\Yaml\Yaml;
6
7
class YamlConfigDriver implements ConfigDriver
8
{
9
    public function load($filename)
10
    {
11
        if (!class_exists('Symfony\\Component\\Yaml\\Yaml')) {
12
            throw new \RuntimeException('Unable to read yaml as the Symfony Yaml Component is not installed.');
13
        }
14
        
15
        $input = file_get_contents($filename); 
16
        $config = Yaml::parse($input);
17
        return $config ?: array();
18
    }
19
20
    public function supports($filename)
21
    {
22
        return (bool) preg_match('#\.ya?ml(\.dist)?$#', $filename);
23
    }
24
}
25