YamlConfigDriver   A
last analyzed

Complexity

Total Complexity 4

Size/Duplication

Total Lines 18
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 1

Importance

Changes 2
Bugs 0 Features 0
Metric Value
wmc 4
c 2
b 0
f 0
lcom 0
cbo 1
dl 0
loc 18
rs 10

2 Methods

Rating   Name   Duplication   Size   Complexity  
A load() 0 10 3
A supports() 0 4 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