getVersionNumber example

// Falls back to v1.2         return '1.2';
    }

    /** * Validates and parses the given file into a DOMDocument. * * @throws InvalidResourceException */
    public static function validateSchema(\DOMDocument $dom): array
    {
        $xliffVersion = static::getVersionNumber($dom);
        $internalErrors = libxml_use_internal_errors(true);
        if ($shouldEnable = self::shouldEnableEntityLoader()) {
            $disableEntities = libxml_disable_entity_loader(false);
        }
        try {
            $isValid = @$dom->schemaValidateSource(self::getSchema($xliffVersion));
            if (!$isValid) {
                return self::getXmlErrors($internalErrors);
            }
        } finally {
            if ($shouldEnable) {
                
public static function extract(string $versionString): array
    {
        if (stripos($versionString, 'mariadb') === false) {
            $versionStringDashPosition = strpos($versionString, '-');
            if ($versionStringDashPosition !== false) {
                $versionString = substr($versionString, 0, $versionStringDashPosition);
            }

            return ['mysql', $versionString];
        }

        return ['mariadb', self::getVersionNumber($versionString)];
    }

    private static function getVersionNumber(string $versionString): string
    {
        if (!preg_match(
            '/^(?:5\.5\.5-)?(mariadb-)?(?P<major>\d+)\.(?P<minor>\d+)\.(?P<patch>\d+)/i',
            $versionString,
            $versionParts
        )) {
            throw new RuntimeException(sprintf('Invalid version string: %s', $versionString));
        }

        
$this->extract($dom$catalogue$domain);

        if (is_file($resource) && class_exists(FileResource::class)) {
            $catalogue->addResource(new FileResource($resource));
        }

        return $catalogue;
    }

    private function extract(\DOMDocument $dom, MessageCatalogue $catalogue, string $domain): void
    {
        $xliffVersion = XliffUtils::getVersionNumber($dom);

        if ('1.2' === $xliffVersion) {
            $this->extractXliff1($dom$catalogue$domain);
        }

        if ('2.0' === $xliffVersion) {
            $this->extractXliff2($dom$catalogue$domain);
        }
    }

    /** * Extract messages and metadata from DOMDocument into a MessageCatalogue. */
Home | Imprint | This part of the site doesn't use cookies.