| Conditions | 3 |
| Paths | 5 |
| Total Lines | 21 |
| Code Lines | 13 |
| Lines | 0 |
| Ratio | 0 % |
| Tests | 13 |
| CRAP Score | 3 |
| Changes | 3 | ||
| Bugs | 2 | Features | 0 |
| 1 | <?php |
||
| 28 | 6 | public function parse($path) |
|
| 29 | { |
||
| 30 | 6 | $data = null; |
|
| 31 | |||
| 32 | try { |
||
| 33 | // Check if the PHP native's YAML extension is exist |
||
| 34 | 6 | if (!extension_loaded('yaml')) { |
|
| 35 | 6 | $data = YamlParser::parse(file_get_contents(realpath($path))); |
|
| 36 | 2 | } else { |
|
| 37 | 1 | $data = yaml_parse_file($path); |
|
| 38 | } |
||
| 39 | 5 | } catch (\Exception $ex) { |
|
| 40 | 3 | throw new ParseException([ |
|
| 41 | 3 | 'message' => 'Error parsing YAML file', |
|
| 42 | 3 | 'file' => $path, |
|
| 43 | 3 | 'exception' => $ex, |
|
| 44 | 2 | ]); |
|
| 45 | } |
||
| 46 | |||
| 47 | 3 | return $data; |
|
| 48 | } |
||
| 49 | |||
| 60 |