| Conditions | 2 |
| Paths | 2 |
| Total Lines | 17 |
| Code Lines | 9 |
| Lines | 0 |
| Ratio | 0 % |
| Changes | 1 | ||
| Bugs | 0 | Features | 1 |
| 1 | <?php |
||
| 32 | public static function readFile(/*# string */ $path) |
||
| 33 | { |
||
| 34 | // check first |
||
| 35 | static::checkPath($path); |
||
| 36 | |||
| 37 | // read it |
||
| 38 | @$data = simplexml_load_file($path); |
||
|
|
|||
| 39 | |||
| 40 | if (false === $data) { |
||
| 41 | libxml_use_internal_errors(true); |
||
| 42 | simplexml_load_file($path, null, \LIBXML_NOERROR); |
||
| 43 | $errors = libxml_get_errors(); |
||
| 44 | throw new RuntimeException($errors[0]->message); |
||
| 45 | } |
||
| 46 | |||
| 47 | return json_decode(json_encode($data), true); |
||
| 48 | } |
||
| 49 | } |
||
| 50 |
If you suppress an error, we recommend checking for the error condition explicitly: