ConfigurationLoader   A
last analyzed

Complexity

Total Complexity 2

Size/Duplication

Total Lines 23
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 3
Metric Value
wmc 2
lcom 0
cbo 3
dl 0
loc 23
rs 10

1 Method

Rating   Name   Duplication   Size   Complexity  
A loadConfiguration() 0 13 2
1
<?php
2
3
/**
4
 * This file is part of cloak.
5
 *
6
 * (c) Noritaka Horio <[email protected]>
7
 *
8
 * This source file is subject to the MIT license that is bundled
9
 * with this source code in the file LICENSE.
10
 */
11
12
namespace cloak\configuration;
13
14
use Yosymfony\Toml\Toml;
15
16
/**
17
 * Class ConfigurationLoader
18
 * @package cloak\configuration
19
 */
20
class ConfigurationLoader
21
{
22
23
    /**
24
     * @param string $configFilePath
25
     * @return \cloak\AnalyzerConfiguration
26
     * @throws \cloak\configuration\ConfigurationFileNotFoundException
27
     */
28
    public function loadConfiguration($configFilePath)
29
    {
30
        if (is_file($configFilePath) === false) {
31
            throw new ConfigurationFileNotFoundException("Configuration file $configFilePath does not exist.");
32
        }
33
34
        $configValues = Toml::parse($configFilePath);
35
36
        $root = new Root($configValues);
37
        $builder = $root->applyTo(new ConfigurationBuilder());
38
39
        return $builder->build();
40
    }
41
42
}
43