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