public static function createArray($inputXml, $version = '1.0', $encoding = 'UTF-8', $formatOutput = true)
    {
        $class = new self($version, $encoding, $formatOutput);
        $xml = $class->xml;

        if (is_string($inputXml)) {

            $parsed = $xml->loadXML($inputXml);

            if (! $parsed) {

                throw new \Exception('[XML2Array] Error parsing the XML string.');

            }

        } else {

            if (get_class($inputXml) !== 'DOMDocument') {

                throw new \Exception('[XML2Array] The input XML object should be of type: DOMDocument.');

            }

            $xml = $class->xml = $inputXml;
        }

        $array = [];
        $array[$xml->documentElement->tagName] = $class->convert($xml->documentElement);

        return $array;
    }