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