ConfigurationManager::load()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 5
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
cc 1
eloc 2
c 1
b 0
f 0
nc 1
nop 0
dl 0
loc 5
rs 10
1
<?php
2
/**
3
 * Created by PhpStorm.
4
 * User: nicolas
5
 * Date: 18/02/17
6
 * Time: 07:07
7
 */
8
9
namespace Devgiants\Configuration;
10
11
12
use Symfony\Component\Config\Definition\Processor;
13
use Symfony\Component\Yaml\Yaml;
14
15
class ConfigurationManager
16
{
17
    /**
18
     * @var string
19
     */
20
    private $configurationFile;
21
22
    public function __construct($filePath) {
23
        $this->configurationFile = $filePath;
24
    }
25
    /**
26
     * @return string
27
     */
28
    public function getConfigurationFile()
29
    {
30
        return $this->configurationFile;
31
    }
32
33
    /**
34
     * @return array
35
     */
36
    public function load() {
37
        // TODO check exception behavior
38
        $configuration = Yaml::parse(file_get_contents($this->configurationFile));
39
40
        return $this->check($configuration);
41
    }
42
43
44
    /**
45
     * @param $configurationUnprocessed
46
     * @return array
47
     */
48
    private function check($configurationUnprocessed) {
49
        $processor = new Processor();
50
        $applicationConfiguration = new ApplicationConfiguration();
51
        $processedConfiguration = $processor->processConfiguration($applicationConfiguration, $configurationUnprocessed);
52
        return $processedConfiguration;
53
    }
54
}