ChainConfigDriver   A
last analyzed

Complexity

Total Complexity 6

Size/Duplication

Total Lines 31
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 0

Importance

Changes 1
Bugs 0 Features 0
Metric Value
wmc 6
c 1
b 0
f 0
lcom 1
cbo 0
dl 0
loc 31
rs 10

4 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 4 1
A load() 0 5 1
A supports() 0 4 1
A getDriver() 0 10 3
1
<?php
2
3
namespace Igorw\Silex;
4
5
use Toml\Parser;
6
7
class ChainConfigDriver implements ConfigDriver
8
{
9
    private $drivers;
10
11
    public function __construct(array $drivers)
12
    {
13
        $this->drivers = $drivers;
14
    }
15
16
    public function load($filename)
17
    {
18
        $driver = $this->getDriver($filename);
19
        return $driver->load($filename);
20
    }
21
22
    public function supports($filename)
23
    {
24
        return (bool) $this->getDriver($filename);
25
    }
26
27
    private function getDriver($filename)
28
    {
29
        foreach ($this->drivers as $driver) {
30
            if ($driver->supports($filename)) {
31
                return $driver;
32
            }
33
        }
34
35
        return null;
36
    }
37
}
38