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