UBL Version resolver.

@param \DOMDocument $document
@return string
774541
public function getVersion(\DOMDocument $document)
    {
        if (empty($document->documentElement)) {
            return '';
        }

        $xpath = $this->getXpath($document);
        $this->setNs($document);
        $xpath->registerNamespace('cbc', self::CBC_NS);

        return $this->getSingleValue($xpath, 'cbc:UBLVersionID');
    }
165248
public function format(\DOMDocument $document) : \DOMDocument
    {
        $element = $document->createElement('feed');
        $element->setAttribute('xmlns', 'http://www.w3.org/2005/Atom');
        $document->appendChild($element);

        return $document;
    }
1177660
private static function getCleanedHTML(DOMDocument $doc, $container)
    {
        while ($doc->firstChild) {
            $doc->removeChild($doc->firstChild);
        }

        while ($container->firstChild ) {
            $doc->appendChild($container->firstChild);
        }

        $html = trim($doc->saveHTML());
        return $html;
    }
404819
protected function document(Document $document = null): ?Document {
        if ($document === null) {
            return $this->document;
        }

        $this->document = $document;

        return $this->document;
    }
944135
public static function getSchemaVersion($xml)
    {
        $doiXML = new \DOMDocument();
        $doiXML->loadXML($xml);

        $resources = $doiXML->getElementsByTagName('resource');
        $theSchema = 'unknown';
        if ($resources->length > 0) {
            if (isset($resources->item(0)->attributes->item(0)->name)) {
                $theSchema = substr($resources->item(0)->attributes->item(0)->nodeValue,
                    strpos($resources->item(0)->attributes->item(0)->nodeValue,
                        "/meta/kernel") + 5);
            }
        }

        return $theSchema;
    }
503630
protected function fixDocument(DOMDocument $document)
    {
        $rootElement = $document->firstChild;

        $xp = new DOMXPath($document);

        $nodes = $xp->query("/testsuites/testsuite/testsuite/testsuite");

        if ($nodes->length === 0) {
            $nodes = $xp->query("/testsuites/testsuite");

            foreach ($nodes as $node) {
                $children = $xp->query("./testsuite", $node);

                if ($children->length) {
                    $this->handleChildren($rootElement, $children);
                    $rootElement->removeChild($node);
                }
            }
        } else {
            $nodes = $xp->query("/testsuites/testsuite/testsuite");

            foreach ($nodes as $node) {
                $children = $xp->query("./testsuite", $node);

                if ($children->length) {
                    $this->handleChildren($rootElement, $children);
                    $rootElement->firstChild->removeChild($node);
                }
            }
        }
    }
376688
public static function parseVersion($version)
    {
        if (preg_match('#^(\d+)\.(\d+)\.(\d+)(\-([\w.\-]+)|)$#', $version, $match)) {
            return (object) array(
                'major' => $match[1],
                'minor' => $match[2],
                'patch' => $match[3],
                'extra' => empty($match[5]) ? null : $match[5]
            );
        }

        return false;
    }
1207145
public function getNormalizedIdentifier($document)
    {
        if (is_scalar($document)) {
            throw new \InvalidArgumentException('Invalid argument, object or null required');
        }

        // the document is not managed
        if (!$document || !$this->getDocumentManager()->contains($document)) {
            return;
        }

        $values = $this->getIdentifierValues($document);

        return $values[0];
    }
1294102
public function getUrl($document)
    {
        $environment = $document->getEnvironment();

        return $environment->getUrl() . '.' . $this->kernel->getFileExtension();
    }
304880
public static function version(string $expression = self::VERSION_WITHOUT_BUG_FIX): string
    {
        if (static::is(static::LARAVEL)) {
            return static::extractVersion(constant('Illuminate\Foundation\Application::VERSION'), $expression);
        }

        /** @var \Laravel\Lumen\Application $app */
        $app = call_user_func('Laravel\Lumen\Application::getInstance');

        if ($version = static::extractVersion($app->version(), $expression)) {
            return $version;
        }

        throw new LogicException('No any version found.');
    }
1227643
private function getFirstChild(\DOMDocument $document)
    {
        foreach ($document->childNodes as $child) {
            if ($child instanceof \DOMElement) {
                return $child;
                // @codeCoverageIgnoreStart
            }
        }

        return false;
        // @codeCoverageIgnoreEnd
    }
268182
public function getParent($document)
    {
        $parentNode = $this->getNode($document)->getParent();

        if (!$parentNode) {
            return;
        }

        return $this->proxyFactory->createProxyForNode($document, $parentNode);
    }
777055
public function getDocumentIdentifier($document)
    {
        return isset($this->documentIdentifiers[spl_object_hash($document)]) ?
            $this->documentIdentifiers[spl_object_hash($document)] : null;
    }
551944
private function getVersionFromObject($object)
    {
        $version = null;

        if ($this->accessor->isReadable($object, self::FIELD_NAME)) {
            $version = $this->accessor->getValue($object, self::FIELD_NAME);
        }
        return $version;
    }
1261349
public function resolveAdditionalWebspaces(WebspaceBehavior $document)
    {
        if (!$this->hasMoreThanOneWebspace()) {
            return [];
        }

        if ($document->getAdditionalWebspaces()) {
            return $document->getAdditionalWebspaces();
        }

        return $this->webspaceSettingsConfigurationResolver->getDefaultAdditionalWebspacesForLocale($document->getOriginalLocale());
    }
502788
public static function getDebugTitle($document)
    {
        $title = spl_object_hash($document);

        if ($document instanceof PathBehavior && $document->getPath()) {
            $title .= ' (' . $document->getPath() . ')';
        } elseif ($document instanceof TitleBehavior && $document->getTitle()) {
            $title .= ' (' . $document->getTitle() . ')';
        }

        return $title;
    }
59402
protected function appendPhpdocStatsElement(\DOMDocument $document)
    {
        $stats = $document->createElement('phpdoc-stats');
        $stats->setAttribute('version', Application::VERSION());
        $document->appendChild($stats);

        return $document;
    }