<html><head><meta name="color-scheme" content="light dark"></head><body><pre style="word-wrap: break-word; white-space: pre-wrap;">&lt;?php

namespace WsdlToPhp\PackageBase;

class Utils
{
    /**
     * Returns a XML string content as a DOMDocument or as a formated XML string
     * @throws \InvalidArgumentException
     * @param string $string
     * @param bool $asDomDocument
     * @return \DOMDocument|string|null
     */
    public static function getFormatedXml($string, $asDomDocument = false)
    {
        @trigger_error(sprintf('%s() will be renamed to getFormattedXml in WsdlToPhp/PackageBase 3.0.', __METHOD__), E_USER_DEPRECATED);

        if (!is_null($string)) {
            $domDocument = self::getDOMDocument($string);
            return $asDomDocument ? $domDocument : $domDocument-&gt;saveXML();
        }
        return null;
    }
    /**
     * @param string $string
     * @throws \InvalidArgumentException
     * @return \DOMDocument
     */
    public static function getDOMDocument($string)
    {
        $dom = new \DOMDocument('1.0', 'UTF-8');
        $dom-&gt;formatOutput = true;
        $dom-&gt;preserveWhiteSpace = false;
        $dom-&gt;resolveExternals = false;
        $dom-&gt;substituteEntities = false;
        $dom-&gt;validateOnParse = false;
        try {
            $dom-&gt;loadXML($string);
        } catch (\Exception $exception) {
            throw new \InvalidArgumentException('XML string is invalid', $exception-&gt;getCode(), $exception);
        }
        return $dom;
    }
}
</pre></body></html>