src/Version/Ios.php
/**
     * returns the version of the operating system/platform
     *
     * @throws UnexpectedValueException
     */
returns the version of the operating system/platform
@throws UnexpectedValueException
returns the version of the operating system / platform @throws UnexpectedValueException
public function detectVersion(string $useragent): VersionInterface
    {
        $doMatch = preg_match('/CPU like Mac OS X/', $useragent);
        if ($doMatch) {
            try {
                return $this->versionFactory->set('1.0');
            } catch (NotNumericException $e) {
                $this->logger->info($e);
                return new NullVersion();
            }
        }
        $doMatch = preg_match('/mobile\/(?P<build>\d+[A-Z]\d+(?:[a-z])?)/i', $useragent, $matches);
        if ($doMatch) {
            try {
                $buildVersion = $this->iosBuild->getVersion($matches['build']);
            } catch (BuildException | NotFoundException $e) {
                $buildVersion = false;
            }
            if (false !== $buildVersion) {
                try {
                    return $this->versionFactory->set($buildVersion);
                } catch (NotNumericException $e) {
                    $this->logger->info($e);
                    return new NullVersion();
                }
            }
        }
        $doMatch = preg_match('/applecoremedia\/\d+\.\d+\.\d+\.(?P<build>\d+[A-Z]\d+(?:[a-z])?)/i', $useragent, $matches);
        if ($doMatch) {
            try {
                $buildVersion = $this->iosBuild->getVersion($matches['build']);
            } catch (BuildException | NotFoundException $e) {
                $buildVersion = false;
            }
            if (false !== $buildVersion) {
                try {
                    return $this->versionFactory->set($buildVersion);
                } catch (NotNumericException $e) {
                    $this->logger->info($e);
                    return new NullVersion();
                }
            }
        }
        if (false !== mb_stripos($useragent, 'darwin')) {
            foreach (self::DARWIN_MAP as $rule => $version) {
                if (!preg_match($rule, $useragent)) {
                    continue;
                }
                try {
                    return $this->versionFactory->set($version);
                } catch (NotNumericException $e) {
                    $this->logger->info($e);
                    return new NullVersion();
                }
            }
        }
        $doMatch = preg_match('/^apple-(?:iphone|ip[ao]d)\d+[c,_]\d+\/(?P<build>[\d\.]+)$/i', $useragent, $matches);
        if ($doMatch) {
            if (array_key_exists($matches['build'], self::BUILD_MAP)) {
                try {
                    return $this->versionFactory->set(self::BUILD_MAP[$matches['build']]);
                } catch (NotNumericException $e) {
                    $this->logger->info($e);
                    return new NullVersion();
                }
            }
        }
        $doMatch = preg_match('/ios\/\d+[\d\.]+ \((?P<build>\d+[A-Z]\d+(?:[a-z])?)\)/i', $useragent, $matches);
        if ($doMatch) {
            try {
                $buildVersion = $this->iosBuild->getVersion($matches['build']);
            } catch (BuildException | NotFoundException $e) {
                $buildVersion = false;
            }
            if (false !== $buildVersion) {
                try {
                    return $this->versionFactory->set($buildVersion);
                } catch (NotNumericException $e) {
                    $this->logger->info($e);
                    return new NullVersion();
                }
            }
        }
        try {
            $detectedVersion = $this->versionFactory->detectVersion($useragent, self::SEARCHES);
        } catch (NotNumericException $e) {
            $this->logger->info($e);
            return new NullVersion();
        }
        if ('10.10' === $detectedVersion->getVersion(VersionInterface::IGNORE_MICRO)) {
            try {
                return $this->versionFactory->set('8.0.0');
            } catch (NotNumericException $e) {
                $this->logger->info($e);
                return new NullVersion();
            }
        }
        return $detectedVersion;
    }
public function detectVersion ( string $ useragent ) : VersionInterface { $ doMatch = preg_match ( '/CPU like Mac OS X/' , $ useragent ) ; if ( $ doMatch ) { try { return $ this -> versionFactory -> set ( '1.0' ) ; } catch ( NotNumericException $ e ) { $ this -> logger -> info ( $ e ) ; return new NullVersion ( ) ; } } $ doMatch = preg_match ( '/mobile\/(?P<build>\d+[A-Z]\d+(?:[a-z])?)/i' , $ useragent , $ matches ) ; if ( $ doMatch ) { try { $ buildVersion = $ this -> iosBuild -> getVersion ( $ matches [ 'build' ] ) ; } catch ( BuildException | NotFoundException $ e ) { $ buildVersion = false ; } if ( false !== $ buildVersion ) { try { return $ this -> versionFactory -> set ( $ buildVersion ) ; } catch ( NotNumericException $ e ) { $ this -> logger -> info ( $ e ) ; return new NullVersion ( ) ; } } } $ doMatch = preg_match ( '/applecoremedia\/\d+\.\d+\.\d+\.(?P<build>\d+[A-Z]\d+(?:[a-z])?)/i' , $ useragent , $ matches ) ; if ( $ doMatch ) { try { $ buildVersion = $ this -> iosBuild -> getVersion ( $ matches [ 'build' ] ) ; } catch ( BuildException | NotFoundException $ e ) { $ buildVersion = false ; } if ( false !== $ buildVersion ) { try { return $ this -> versionFactory -> set ( $ buildVersion ) ; } catch ( NotNumericException $ e ) { $ this -> logger -> info ( $ e ) ; return new NullVersion ( ) ; } } } if ( false !== mb_stripos ( $ useragent , 'darwin' ) ) { foreach ( self :: DARWIN_MAP as $ rule => $ version ) { if ( ! preg_match ( $ rule , $ useragent ) ) { continue ; } try { return $ this -> versionFactory -> set ( $ version ) ; } catch ( NotNumericException $ e ) { $ this -> logger -> info ( $ e ) ; return new NullVersion ( ) ; } } } $ doMatch = preg_match ( '/^apple-(?:iphone|ip[ao]d)\d+[c,_]\d+\/(?P<build>[\d\.]+)$/i' , $ useragent , $ matches ) ; if ( $ doMatch ) { if ( array_key_exists ( $ matches [ 'build' ] , self :: BUILD_MAP ) ) { try { return $ this -> versionFactory -> set ( self :: BUILD_MAP [ $ matches [ 'build' ] ] ) ; } catch ( NotNumericException $ e ) { $ this -> logger -> info ( $ e ) ; return new NullVersion ( ) ; } } } $ doMatch = preg_match ( '/ios\/\d+[\d\.]+ \((?P<build>\d+[A-Z]\d+(?:[a-z])?)\)/i' , $ useragent , $ matches ) ; if ( $ doMatch ) { try { $ buildVersion = $ this -> iosBuild -> getVersion ( $ matches [ 'build' ] ) ; } catch ( BuildException | NotFoundException $ e ) { $ buildVersion = false ; } if ( false !== $ buildVersion ) { try { return $ this -> versionFactory -> set ( $ buildVersion ) ; } catch ( NotNumericException $ e ) { $ this -> logger -> info ( $ e ) ; return new NullVersion ( ) ; } } } try { $ detectedVersion = $ this -> versionFactory -> detectVersion ( $ useragent , self :: SEARCHES ) ; } catch ( NotNumericException $ e ) { $ this -> logger -> info ( $ e ) ; return new NullVersion ( ) ; } if ( '10.10' === $ detectedVersion -> getVersion ( VersionInterface :: IGNORE_MICRO ) ) { try { return $ this -> versionFactory -> set ( '8.0.0' ) ; } catch ( NotNumericException $ e ) { $ this -> logger -> info ( $ e ) ; return new NullVersion ( ) ; } } return $ detectedVersion ; }
returns the version of the operating system/platform
 @throws UnexpectedValueException
returns the version of the operating system / platform @throws UnexpectedValueException