ChainConfigDriver::getDriver()   A
last analyzed

Complexity

Conditions 3
Paths 3

Size

Total Lines 10
Code Lines 5

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
c 1
b 0
f 0
dl 0
loc 10
rs 9.4286
cc 3
eloc 5
nc 3
nop 1
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