@param string $userAgent

@return string
423656
public function normalize($userAgent)
    {
        // Repair Opera user agents using fake version 9.80
        // Normalize: Opera/9.80 (X11; Linux x86_64; U; sv) Presto/2.9.168 Version/11.50
        // Into: Opera/11.50 (X11; Linux x86_64; U; sv) Presto/2.9.168 Version/11.50
        if (Utils::checkIfStartsWith($userAgent, 'Opera/9.80')) {
            if (preg_match('#Version/(\d+\.\d+)#', $userAgent, $matches)) {
                $userAgent = str_replace('Opera/9.80', 'Opera/' . $matches[1], $userAgent);
            }

            //Match to the '.' in the Opera version number
            return $userAgent;
        }
        //Normalize Opera v15 and above UAs, that say OPR, into 'Opera/version UA' format used above
        if (preg_match('#OPR/(\d+\.\d+)#', $userAgent, $matches)) {
            $prefix    = 'Opera/' . $matches[1] . ' ';
            $userAgent = $prefix . $userAgent;
        }

        return $userAgent;
    }
74508
private function chromeWithMajorVersion($userAgent) {
		$start_idx = strpos($userAgent, 'Chrome');
		$end_idx = strpos($userAgent, '.', $start_idx);
		if ($end_idx === false) {
			return substr($userAgent, $start_idx);
		} else {
			return substr($userAgent, $start_idx, ($end_idx - $start_idx));
		}
	}
390757
public function normalize($userAgent)
    {
        // Starts with 'JUC' or 'Mozilla/5.0(Linux;U;Android'
        if (strpos($userAgent, 'JUC') === 0 || strpos($userAgent, 'Mozilla/5.0(Linux;U;Android') === 0) {
            $userAgent = preg_replace('/^(JUC \(Linux; U;)(?= \d)/', '$1 Android', $userAgent);
            $userAgent = preg_replace('/(Android|JUC|[;\)])(?=[\w|\(])/', '$1 ', $userAgent);
        }

        return $userAgent;
    }
255824
public function applyRecoveryMatch($userAgent)
    {
        if (Utils::checkIfContainsAnyOf($userAgent, array('WPDesktop', 'ZuneWP7'))
            || Utils::checkIfContainsAll($userAgent, array('Mozilla/5.0 (Windows NT ', ' ARM;', ' Edge/'))
        ) {
            if (Utils::checkIfContainsAll($userAgent, array('Mozilla/5.0 (Windows NT ', ' ARM;', ' Edge/'))) {
                return 'generic_ms_phone_os10_desktopmode';
            }

            if (Utils::checkIfContains($userAgent, 'WPDesktop')) {
                return 'generic_ms_phone_os8_desktopmode';
            }

            if (Utils::checkIfContains($userAgent, 'Trident/5.0')) {
                return 'generic_ms_phone_os7_5_desktopmode';
            }

            return 'generic_ms_phone_os7_desktopmode';
        }

        $version = self::getWindowsPhoneVersion($userAgent);

        if ($version === '10.0') {
            return 'generic_ms_phone_os10';
        }

        if ($version === '8.1') {
            return 'generic_ms_phone_os8_1';
        }

        if ($version === '8.0') {
            return 'generic_ms_phone_os8';
        }

        if ($version === '7.8') {
            return 'generic_ms_phone_os7_8';
        }

        if ($version === '7.5') {
            return 'generic_ms_phone_os7_5';
        }

        if ($version === '7.0') {
            return 'generic_ms_phone_os7';
        }

        if ($version === '6.5') {
            return 'generic_ms_winmo6_5';
        }

        //These are probably UAs of the type "Windows Phone Ad Client (Xna)/5.1.0.0 BMID/E67970D969"
        if (Utils::checkIfStartsWithAnyOf($userAgent, array('Windows Phone Ad Client', 'WindowsPhoneAdClient'))) {
            return 'generic_ms_phone_os7';
        }

        return WurflConstants::NO_MATCH;
    }
313882
public function userAgent($useragent) {

		if(false === is_string($useragent)) {
            return trigger_error(sprintf('Argument 1 passed to %s() must be of the type string, "%s" given', __METHOD__, gettype($useragent)), E_USER_ERROR);
        }

		$this -> options[CURLOPT_USERAGENT] = $useragent;

		return $this;
	}
770866
public function applyConclusiveMatch($userAgent)
    {
        // Example Windows 8 RT MSIE 10 UA:
        // Mozilla/5.0 (compatible; MSIE 10.0; Windows NT 6.2; ARM; Trident/6.0; Touch)
        //                                                        ^ RIS Tolerance
        //Example Windows 8.1 RT MSIE 11 UA
        //Mozilla/5.0 (Windows NT 6.3; ARM; Trident/7.0; Touch; rv:11.0) like Gecko
        //																    	  ^ RIS Tolerance

        if (Utils::checkIfContainsAll($userAgent, array('like Gecko'))) {
            //Use this logic for MSIE 11 and above
            $search = ' Gecko';
            $idx    = strpos($userAgent, $search);
            if ($idx !== false) {
                // Match to the end of the search string
                return $this->getDeviceIDFromRIS($userAgent, $idx + strlen($search));
            }
        } else {
            $search = ' ARM;';
            $idx    = strpos($userAgent, $search);
            if ($idx !== false) {
                // Match to the end of the search string
                return $this->getDeviceIDFromRIS($userAgent, $idx + strlen($search));
            }
        }

        return WurflConstants::NO_MATCH;
    }
213548
public static function clientInfo($useragent = '') {
		if (!$useragent) {
			$useragent = self::getIndpEnv('HTTP_USER_AGENT');
		}

		$bInfo = array();
			// Which browser?
		if (strpos($useragent, 'Konqueror') !== FALSE) {
			$bInfo['BROWSER'] = 'konqu';
		} elseif (strpos($useragent, 'Opera') !== FALSE) {
			$bInfo['BROWSER'] = 'opera';
		} elseif (strpos($useragent, 'MSIE') !== FALSE) {
			$bInfo['BROWSER'] = 'msie';
		} elseif (strpos($useragent, 'Mozilla') !== FALSE) {
			$bInfo['BROWSER'] = 'net';
		} elseif (strpos($useragent, 'Flash') !== FALSE) {
			$bInfo['BROWSER'] = 'flash';
		}
		if ($bInfo['BROWSER']) {
				// Browser version
			switch ($bInfo['BROWSER']) {
				case 'net':
					$bInfo['VERSION'] = doubleval(substr($useragent, 8));
					if (strpos($useragent, 'Netscape6/') !== FALSE) {
						$bInfo['VERSION'] = doubleval(substr(strstr($useragent, 'Netscape6/'), 10));
					} // Will we ever know if this was a typo or intention...?! :-(
					if (strpos($useragent, 'Netscape/6') !== FALSE) {
						$bInfo['VERSION'] = doubleval(substr(strstr($useragent, 'Netscape/6'), 10));
					}
					if (strpos($useragent, 'Netscape/7') !== FALSE) {
						$bInfo['VERSION'] = doubleval(substr(strstr($useragent, 'Netscape/7'), 9));
					}
					break;
				case 'msie':
					$tmp = strstr($useragent, 'MSIE');
					$bInfo['VERSION'] = doubleval(preg_replace('/^[^0-9]*/', '', substr($tmp, 4)));
					break;
				case 'opera':
					$tmp = strstr($useragent, 'Opera');
					$bInfo['VERSION'] = doubleval(preg_replace('/^[^0-9]*/', '', substr($tmp, 5)));
					break;
				case 'konqu':
					$tmp = strstr($useragent, 'Konqueror/');
					$bInfo['VERSION'] = doubleval(substr($tmp, 10));
					break;
			}
			// Client system
			if (strpos($useragent, 'Win') !== FALSE) {
				$bInfo['SYSTEM'] = 'win';
			} elseif (strpos($useragent, 'Mac') !== FALSE) {
				$bInfo['SYSTEM'] = 'mac';
			} elseif (strpos($useragent, 'Linux') !== FALSE || strpos($useragent, 'X11') !== FALSE || strpos($useragent, 'SGI') !== FALSE || strpos($useragent, ' SunOS ') !== FALSE || strpos($useragent, ' HP-UX ') !== FALSE) {
				$bInfo['SYSTEM'] = 'unix';
			}
		}
		// Is TRUE if the browser supports css to format forms, especially the width
		$bInfo['FORMSTYLE'] = ($bInfo['BROWSER'] == 'msie' || ($bInfo['BROWSER'] == 'net' && $bInfo['VERSION'] >= 5) || $bInfo['BROWSER'] == 'opera' || $bInfo['BROWSER'] == 'konqu');

		return $bInfo;
	}
454933
public static function getMaemoModel($userAgent)
    {
        if (preg_match('/Maemo [bB]rowser [\d\.]+ (.+)/', $userAgent, $matches)) {
            $model = $matches[1];
            $idx   = strpos($model, ' GTB');

            if ($idx !== false) {
                $model = substr($model, 0, $idx);
            }

            return $model;
        }

        return WurflConstants::NO_MATCH;
    }
554494
public function normalize($userAgent)
    {
        $model = HTCMacHandler::getHTCMacModel($userAgent, false);

        if ($model !== null) {
            $prefix = $model . WurflConstants::RIS_DELIMITER;

            return $prefix . $userAgent;
        }

        return $userAgent;
    }
942970
public static function isRobot($userAgent)
    {
        self::$isRobot = false;
        $userAgent     = strtolower($userAgent);

        foreach (self::$robots as $key) {
            if (strpos($userAgent, $key) !== false) {
                self::$isRobot = true;
                break;
            }
        }

        return self::$isRobot;
    }
488282
protected function filterBrowserNames(array $userAgent)
    {
        // IE11 hasn't 'MSIE' in its user agent string
        if (empty($userAgent['browser_name']) && $userAgent['browser_engine'] === 'trident' && strpos($userAgent['string'], 'rv:')) {
            $userAgent['browser_name'] = 'msie';
            $userAgent['browser_version'] = preg_replace('|.+rv:([0-9]+(?:\.[0-9]+)+).+|', '$1', $userAgent['string']);

            return $userAgent;
        }

        return $userAgent;
    }
1371908
public function normalize(string $userAgent): string
    {
        $userAgent = preg_replace('/([\d]+)EMobile/', '$1; IEMobile', $userAgent);

        $userAgent = str_replace(
            ['Macintoshntel', 'cpu=PPC=Mac'],
            ['Macintosh; Intel', 'cpu=PPC;os=Mac'],
            $userAgent
        );

        $userAgent = preg_replace('/([\\\\]+)/i', '', $userAgent);
        $userAgent = preg_replace('/Versio\//', 'Version/', $userAgent);

        $userAgent = str_replace(
            ['i686 (x86_64)', 'X11buntu', 'Chr0me'],
            ['i686 on x86_64', 'X11; Ubuntu', 'Chrome'],
            $userAgent
        );

        return $userAgent;
    }
448366
public function normalize($userAgent)
    {
        $index = strpos($userAgent, 'UP.Link');

        if ($index !== false) {
            return substr($userAgent, 0, $index);
        }

        return $userAgent;
    }
1008399
public function applyConclusiveMatch($userAgent)
    {
        $operaIndex = strpos($userAgent, 'Opera');
        $tolerance  = Utils::indexOfOrLength($userAgent, '.', $operaIndex);

        return $this->getDeviceIDFromRIS($userAgent, $tolerance);
    }
772925
public function normalize($userAgent)
    {
        $ucbVersion = UcwebU3Handler::getUcBrowserVersion($userAgent);

        if ($ucbVersion === null) {
            return $userAgent;
        }

        //Android U2K Mobile + Tablet
        if (Utils::checkIfContains($userAgent, 'Adr ')) {
            $model   = UcwebU3Handler::getUcAndroidModel($userAgent, false);
            $version = UcwebU3Handler::getUcAndroidVersion($userAgent, false);

            if ($model !== null && $version !== null) {
                $prefix = $version . ' U2Android ' . $ucbVersion . ' ' . $model . WurflConstants::RIS_DELIMITER;

                return $prefix . $userAgent;
            }
        } elseif (Utils::checkIfContains($userAgent, 'iPh OS')) {
            //iPhone U2K
            if (preg_match('/iPh OS (\d)_?(\d)?[ _\d]?.+; iPh(\d), ?(\d)\) U2/', $userAgent, $matches)) {
                $version = $matches[1] . '.' . $matches[2];
                $model   = $matches[3] . '.' . $matches[4];
                $prefix  = $version . ' U2iPhone ' . $ucbVersion . ' ' . $model . WurflConstants::RIS_DELIMITER;

                return $prefix . $userAgent;
            }
        } elseif (Utils::checkIfContains($userAgent, 'wds')) {
            //WP7&8 U2K
            //Add spaces and normalize
            $userAgent = preg_replace('|;(?! )|', '; ', $userAgent);
            if (preg_match(
                '/^UCWEB.+; wds (\d+)\.([\d]+);.+; ([ A-Za-z0-9_-]+); ([ A-Za-z0-9_-]+)\) U2/',
                $userAgent,
                $matches
            )) {
                $version = $matches[1] . '.' . $matches[2];
                $model   = $matches[3] . '.' . $matches[4];
                //Standard normalization stuff from WP matcher
                $model  = str_replace('_blocked', '', $model);
                $model  = preg_replace('/(NOKIA.RM-.+?)_.*/', '$1', $model, 1);
                $prefix = $version . ' U2WindowsPhone ' . $ucbVersion . ' ' . $model . WurflConstants::RIS_DELIMITER;

                return $prefix . $userAgent;
            }
        } elseif (Utils::checkIfContains($userAgent, 'Symbian')) {
            //Symbian U2K
            if (preg_match('/^UCWEB.+; S60 V(\d); .+; (.+)\) U2/', $userAgent, $matches)) {
                $version = 'S60 V' . $matches[1];
                $model   = $matches[2];
                $prefix  = $version . ' U2Symbian ' . $ucbVersion . ' ' . $model . WurflConstants::RIS_DELIMITER;

                return $prefix . $userAgent;
            }
        } elseif (Utils::checkIfContains($userAgent, 'Java')) {
            //Java U2K - check results for regex
            if (preg_match('/^UCWEB[^\(]+\(Java; .+; (.+)\) U2/', $userAgent, $matches)) {
                $version = 'Java';
                $model   = $matches[1];
                $prefix  = $version . ' U2JavaApp ' . $ucbVersion . ' ' . $model . WurflConstants::RIS_DELIMITER;

                return $prefix . $userAgent;
            }
        }

        return $userAgent;
    }
61705
public function BD_CheckBotAgent($UserAgent = false)
    {
        // Check if user agent present
        if ($UserAgent === false)
        {
            $UserAgent = trim(\Environment::get('httpUserAgent'));
        }
        return \BugBuster\BotDetection\CheckBotAgentSimple::checkAgent( $UserAgent );
    }
117499
public function robot($userAgent = null)
    {
        return $this->isRobot($userAgent)
            ? ucfirst($this->getCrawlerDetector()->getMatches())
            : false;
    }