public function detectVersion(string $useragent, array $searches = [], string $default = '0'): VersionInterface
    {
        $modifiers = [
            ['\/', ''],
            ['\(', '\)'],
            [' ', ';'],
            [' ', ''],
            ['', ''],
            [' \(', ';'],
        ];

        $version = $default;

        if (false !== mb_strpos($useragent, '%')) {
            $useragent = urldecode($useragent);
        }

        foreach ($searches as $search) {
            if (!is_string($search)) {
                continue;
            }

            if (false !== mb_strpos($search, '%')) {
                $search = urldecode($search);
            }

            foreach ($modifiers as $modifier) {
                $compareString = '/' . $search . $modifier[0] . '(\d+[\d._\-+ abcdehlprstv]*)' . $modifier[1] . '/i';
                $matches       = [];
                $doMatch       = preg_match($compareString, $useragent, $matches);

                if ($doMatch) {
                    $version = mb_strtolower(str_replace('_', '.', $matches[1]));

                    break 2;
                }
            }
        }

        return $this->set($version);
    }
public function detectVersion(string $useragent, array $searches = [], string $default = '0'): VersionInterface
    {
        $modifiers = [
            ['\/', ''],
            ['\(', '\)'],
            [' ', ';'],
            [' ', ''],
            ['', ''],
            [' \(', ';'],
        ];

        $version = $default;

        if (false !== mb_strpos($useragent, '%')) {
            $useragent = urldecode($useragent);
        }

        foreach ($searches as $search) {
            if (!is_string($search)) {
                continue;
            }

            if (false !== mb_strpos($search, '%')) {
                $search = urldecode($search);
            }

            foreach ($modifiers as $modifier) {
                $compareString = '/' . $search . $modifier[0] . '(\d+[\d._\-+ abcdehlprstv]*)' . $modifier[1] . '/i';
                $matches       = [];
                $doMatch       = preg_match($compareString, $useragent, $matches);

                if ($doMatch) {
                    $version = mb_strtolower(str_replace('_', '.', $matches[1]));

                    break 2;
                }
            }
        }

        return $this->set($version);
    }
public function detectVersion ( string $ useragent , array $ searches = [ ] , string $ default = '0' ) : VersionInterface { $ modifiers = [ [ '\/' , '' ] , [ '\(' , '\)' ] , [ ' ' , ';' ] , [ ' ' , '' ] , [ '' , '' ] , [ ' \(' , ';' ] , ] ; $ version = $ default ; if ( false !== mb_strpos ( $ useragent , '%' ) ) { $ useragent = urldecode ( $ useragent ) ; } foreach ( $ searches as $ search ) { if ( ! is_string ( $ search ) ) { continue ; } if ( false !== mb_strpos ( $ search , '%' ) ) { $ search = urldecode ( $ search ) ; } foreach ( $ modifiers as $ modifier ) { $ compareString = '/' . $ search . $ modifier [ 0 ] . '(\d+[\d._\-+ abcdehlprstv]*)' . $ modifier [ 1 ] . '/i' ; $ matches = [ ] ; $ doMatch = preg_match ( $ compareString , $ useragent , $ matches ) ; if ( $ doMatch ) { $ version = mb_strtolower ( str_replace ( '_' , '.' , $ matches [ 1 ] ) ) ; break 2 ; } } } return $ this -> set ( $ version ) ; }
detects the bit count by this browser from the given user agent

@param string $useragent
@param array  $searches
@param string $default

@return \BrowserDetector\Version\VersionInterface
detects the bit count by this browser from the given user agent