| Conditions | 5 |
| Paths | 5 |
| Total Lines | 31 |
| Code Lines | 18 |
| Lines | 0 |
| Ratio | 0 % |
| Tests | 12 |
| CRAP Score | 5.9256 |
| Changes | 1 | ||
| Bugs | 0 | Features | 0 |
| 1 | <?php |
||
| 36 | 1 | public function load() |
|
| 37 | { |
||
| 38 | 1 | if (file_exists($this->filepath) && ($contents = file_get_contents($this->filepath))) { |
|
| 39 | 1 | $yaml = new Parser(); |
|
| 40 | 1 | $config = $yaml->parse($contents); |
|
| 41 | |||
| 42 | 1 | if (null === $config) { |
|
| 43 | $config = array(); |
||
| 44 | } |
||
| 45 | |||
| 46 | 1 | $processor = new Processor(); |
|
| 47 | 1 | $configDefinition = new ConfigDefinition(); |
|
| 48 | 1 | $processedConfiguration = $processor->processConfiguration( |
|
| 49 | 1 | $configDefinition, |
|
| 50 | $config |
||
| 51 | 1 | ); |
|
| 52 | |||
| 53 | 1 | if (empty($processedConfiguration)) { |
|
| 54 | throw new Exception( |
||
| 55 | 'You need to specify at least one gaguge in the configuration file' |
||
| 56 | ); |
||
| 57 | } |
||
| 58 | |||
| 59 | 1 | 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 |