| Total Complexity | 5 |
| Total Lines | 41 |
| Duplicated Lines | 0 % |
| Coverage | 100% |
| Changes | 1 | ||
| Bugs | 0 | Features | 0 |
| 1 | <?php |
||
| 12 | class Utils |
||
| 13 | { |
||
| 14 | 55 | /** |
|
| 15 | * Returns a XML string content as a DOMDocument or as a formated XML string |
||
| 16 | 55 | * @throws InvalidArgumentException |
|
| 17 | 45 | * @param string|null $string |
|
| 18 | 30 | * @param bool $asDomDocument |
|
| 19 | * @return DOMDocument|string|null |
||
| 20 | 10 | */ |
|
| 21 | public static function getFormattedXml(?string $string, bool $asDomDocument = false) |
||
| 22 | { |
||
| 23 | if (!is_null($string)) { |
||
| 24 | $domDocument = self::getDOMDocument($string); |
||
| 25 | |||
| 26 | return $asDomDocument ? $domDocument : $domDocument->saveXML(); |
||
| 27 | 55 | } |
|
| 28 | |||
| 29 | 55 | return null; |
|
| 30 | 55 | } |
|
| 31 | 55 | ||
| 32 | 55 | /** |
|
| 33 | 55 | * @param string $string |
|
| 34 | 55 | * @return DOMDocument |
|
| 35 | * @throws InvalidArgumentException|ValueError |
||
| 36 | 55 | */ |
|
| 37 | 34 | public static function getDOMDocument(string $string): DOMDocument |
|
| 53 | } |
||
| 54 | } |
||
| 55 |