asXML(); return false === $xml ? '' : $xml; } throw new InvalidXmlException(sprintf( "Not a valid SimpleXMLElement: %s", serialize($data) )); } /** * @return SimpleXMLElement */ public static function unserialize(string $data, array $options = []): SimpleXMLElement { $result = simplexml_load_string($data); if (false === $result) { $errors = libxml_get_errors(); libxml_clear_errors(); throw new InvalidXmlException(sprintf( "Not a valid XML: %s", serialize($errors) )); } return $result; } }