Conditions | 5 |
Paths | 5 |
Total Lines | 31 |
Code Lines | 18 |
Lines | 0 |
Ratio | 0 % |
Tests | 0 |
CRAP Score | 30 |
Changes | 1 | ||
Bugs | 0 | Features | 0 |
1 | <?php |
||
36 | public function load() |
||
37 | { |
||
38 | if (file_exists($this->filepath) && ($contents = file_get_contents($this->filepath))) { |
||
39 | $yaml = new Parser(); |
||
40 | $config = $yaml->parse($contents); |
||
41 | |||
42 | if (null === $config) { |
||
43 | $config = array(); |
||
44 | } |
||
45 | |||
46 | $processor = new Processor(); |
||
47 | $configDefinition = new ConfigDefinition(); |
||
48 | $processedConfiguration = $processor->processConfiguration( |
||
49 | $configDefinition, |
||
50 | $config |
||
51 | ); |
||
52 | |||
53 | if (empty($processedConfiguration)) { |
||
54 | throw new Exception( |
||
55 | 'You need to specify at least one gaguge in the configuration file' |
||
56 | ); |
||
57 | } |
||
58 | |||
59 | return $processedConfiguration; |
||
60 | } |
||
61 | else { |
||
62 | throw new \RuntimeException(sprintf('Configuration file does not exist or is not accessible %s', |
||
63 | $this->filepath)); |
||
64 | } |
||
65 | |||
66 | } |
||
67 | } |
||
68 |