public static function getVersionNumber(DOMDocument $dom): string
    {
        /** @var \DOMNode $xliff */
        foreach ($dom->getElementsByTagName('xliff') as $xliff) {
            if (($version = $xliff->attributes->getNamedItem('version')) !== null) {
                return $version->nodeValue;
            }

            if ($namespace = $xliff->attributes->getNamedItem('xmlns')) {
                if (\substr_compare('urn:oasis:names:tc:xliff:document:', $namespace, 0, 34) !== 0) {
                    throw new InvalidArgumentException(\sprintf('Not a valid XLIFF namespace [%s].', $namespace));
                }

                return \mb_substr($namespace, 34);
            }
        }

        return '1.2'; // Falls back to v1.2
    }
public static function getVersionNumber(DOMDocument $dom): string
    {
        /** @var \DOMNode $xliff */
        foreach ($dom->getElementsByTagName('xliff') as $xliff) {
            if (($version = $xliff->attributes->getNamedItem('version')) !== null) {
                return $version->nodeValue;
            }

            if ($namespace = $xliff->attributes->getNamedItem('xmlns')) {
                if (\substr_compare('urn:oasis:names:tc:xliff:document:', $namespace, 0, 34) !== 0) {
                    throw new InvalidArgumentException(\sprintf('Not a valid XLIFF namespace [%s].', $namespace));
                }

                return \mb_substr($namespace, 34);
            }
        }

        return '1.2'; // Falls back to v1.2
    }
public static function getVersionNumber ( DOMDocument $ dom ) : string { /** @var \DOMNode $xliff */ foreach ( $ dom -> getElementsByTagName ( 'xliff' ) as $ xliff ) { if ( ( $ version = $ xliff -> attributes -> getNamedItem ( 'version' ) ) !== null ) { return $ version -> nodeValue ; } if ( $ namespace = $ xliff -> attributes -> getNamedItem ( 'xmlns' ) ) { if ( \ substr_compare ( 'urn:oasis:names:tc:xliff:document:' , $ namespace , 0 , 34 ) !== 0 ) { throw new InvalidArgumentException ( \ sprintf ( 'Not a valid XLIFF namespace [%s].' , $ namespace ) ) ; } return \ mb_substr ( $ namespace , 34 ) ; } } return '1.2' ; // Falls back to v1.2 }
Gets xliff file version based on the root "version" attribute.
Defaults to 1.2 for backwards compatibility.

@param \DOMDocument $dom

@throws \Viserio\Component\Contract\Parser\Exception\InvalidArgumentException;

@return string
Gets xliff file version based on the root version attribute . Defaults to 1 . 2 for backwards compatibility .