private function createDocument(?string $version = null, ?string $encoding = null): \DOMDocument
    {
        $doc = new \DOMDocument($version ?: $this->defaultVersion, $encoding ?: $this->defaultEncoding);
        $doc->formatOutput = true;

        return $doc;
    }