Conditions | 2 |
Paths | 5 |
Total Lines | 15 |
Code Lines | 11 |
Lines | 0 |
Ratio | 0 % |
Tests | 0 |
CRAP Score | 6 |
Changes | 0 |
1 | <?php |
||
35 | public function toXml(?string $xml): \SimpleXMLElement |
||
36 | { |
||
37 | try { |
||
38 | libxml_use_internal_errors(true); |
||
39 | $xml = simplexml_load_string($xml); |
||
40 | if ($xml === false) { |
||
41 | $errors = libxml_get_errors(); |
||
42 | throw new Exception\Illegible($xml, "Invalid XML. " . implode(". ", $errors)); |
||
43 | } |
||
44 | return $xml; |
||
45 | } finally { |
||
46 | libxml_clear_errors(); |
||
47 | libxml_use_internal_errors(true); |
||
48 | } |
||
49 | } |
||
50 | } |
||
51 |