| Conditions | 2 |
| Paths | 2 |
| Total Lines | 16 |
| Code Lines | 11 |
| Lines | 0 |
| Ratio | 0 % |
| Tests | 3 |
| CRAP Score | 2 |
| Changes | 0 | ||
| 1 | <?php |
||
| 37 | 34 | public static function getDOMDocument(string $string): DOMDocument |
|
| 38 | 20 | { |
|
| 39 | $dom = new DOMDocument('1.0', 'UTF-8'); |
||
| 40 | 35 | $dom->formatOutput = true; |
|
| 41 | $dom->preserveWhiteSpace = false; |
||
| 42 | $dom->resolveExternals = false; |
||
| 43 | $dom->substituteEntities = false; |
||
| 44 | $dom->validateOnParse = false; |
||
| 45 | |||
| 46 | try { |
||
| 47 | $dom->loadXML($string); |
||
| 48 | } catch (Exception $exception) { |
||
| 49 | throw new InvalidArgumentException('XML string is invalid', $exception->getCode(), $exception); |
||
| 50 | } |
||
| 51 | |||
| 52 | return $dom; |
||
| 53 | } |
||
| 55 |