Returns true if the give $userAgent is from a mobile device
@param string $userAgent
@return bool
12919
public static function isMobileBrowser($userAgent)
    {
        if (self::$_is_mobile_browser !== null) {
            return self::$_is_mobile_browser;
        }
        self::$_is_mobile_browser = false;
        $userAgent = strtolower($userAgent);
        foreach (self::$mobileBrowsers as $key) {
            if (strpos($userAgent, $key) !== false) {
                self::$_is_mobile_browser = true;
                break;
            }
        }
        return self::$_is_mobile_browser;
    }
1235516
public function getDeviceForUserAgent($userAgent = '')
    {
        if (!is_string($userAgent)) {
            $userAgent = '';
        }

        $requestFactory = new Request\GenericRequestFactory();

        $request = $requestFactory->createRequestForUserAgent($userAgent);
        $device  = $this->getDeviceForRequest($request);

        return $device;
    }
818624
protected function detectRobot($userAgent)
	{
		if (preg_match('/http|bot|bingbot|googlebot|robot|spider|slurp|crawler|curl|^$/i', $userAgent))
		{
			$this->robot = true;
		}
		else
		{
			$this->robot = false;
		}

		$this->detection['robot'] = true;
	}
1055128
public static function getInstance($userAgent)
    {
        if (array_key_exists($userAgent, self::$deviceDetectorInstances)) {
            return self::$deviceDetectorInstances[$userAgent];
        }

        $deviceDetector = new DeviceDetector($userAgent);
        $deviceDetector->discardBotInformation();
        $deviceDetector->setCache(new DeviceDetectorCache(86400));
        $deviceDetector->parse();

        self::$deviceDetectorInstances[$userAgent] = $deviceDetector;

        return $deviceDetector;
    }
179322
public function applyRecoveryMatch($userAgent)
    {
        if (Utils::checkIfContains($userAgent, 'Series60')) {
            return 'nokia_generic_series60';
        }

        if (Utils::checkIfContains($userAgent, 'Series80')) {
            return 'nokia_generic_series80';
        }

        if (Utils::checkIfContains($userAgent, 'MeeGo')) {
            return 'nokia_generic_meego';
        }

        return WurflConstants::NO_MATCH;
    }
748623
public function canHandle($userAgent)
    {
        if (Utils::isDesktopBrowser($userAgent)) {
            return false;
        }

        return Utils::checkIfContainsCaseInsensitive($userAgent, 'samsung')
            || Utils::checkIfStartsWithAnyOf($userAgent, array('SEC-', 'SPH', 'SGH', 'SCH'));
    }
1328688
public static function isMobileBrowser($userAgent)
    {
        $userAgent_lower = strtolower($userAgent);
        if (self::$isMobileBrowser === null) {
            if (self::isDesktopBrowser($userAgent)) {
                self::$isMobileBrowser = false;
            } elseif (self::checkIfContainsAnyOf($userAgent_lower, self::$mobileBrowsers)) {
                self::$isMobileBrowser = true;
            } elseif (self::regexContains($userAgent, '/[^\d]\d{3}x\d{3}/')) {
                self::$isMobileBrowser = true;
            } else {
                self::$isMobileBrowser = false;
            }
        }

        return self::$isMobileBrowser;
    }
397074
public static function getUcAndroidModel($userAgent)
    {
        // Locales are optional for matching model name since UAs like Chrome Mobile do not contain them
        if (!preg_match('#Adr [\d\.]+; [a-zA-Z]+-[a-zA-Z]+; (.*)\) U2#', $userAgent, $matches)) {
            return null;
        }

        $model = $matches[1];

        // HTC
        if (strpos($model, 'HTC') !== false) {
            // Normalize "HTC/"
            $model = preg_replace('#HTC[ _\-/]#', 'HTC~', $model);
            // Remove the version
            $model = preg_replace('#(/| +V?\d)[\.\d]+$#', '', $model);
            $model = preg_replace('#/.*$#', '', $model);
        }

        // Samsung
        $model = preg_replace('#(SAMSUNG[^/]+)/.*$#', '$1', $model);
        // Orange
        $model = preg_replace('#ORANGE/.*$#', 'ORANGE', $model);
        // LG
        $model = preg_replace('#(LG-[A-Za-z0-9\-]+).*$#', '$1', $model);
        // Serial Number
        $model = preg_replace('#\[[\d]{10}\]#', '', $model);

        $model = trim($model);

        return (strlen($model) === 0) ? null : $model;
    }
54743
private static function checkIpad(Device $device, UserAgent $userAgent)
    {
        if (stripos($userAgent->getUserAgentString(), 'ipad') !== false) {
            $device->setName(Device::IPAD);
            return true;
        }

        return false;
    }
1337071
public static function detect(Os $os, UserAgent $userAgent)
    {
        $os->setName($os::UNKNOWN);
        $os->setVersion($os::VERSION_UNKNOWN);
        $os->setIsMobile(false);

        self::checkMobileBrowsers($os, $userAgent);

        return (
            // Chrome OS before OS X
            self::checkChromeOs($os, $userAgent) ||
            // iOS before OS X
            self::checkIOS($os, $userAgent) ||
            self::checkOSX($os, $userAgent) ||
            self::checkSymbOS($os, $userAgent) ||
            self::checkWindows($os, $userAgent) ||
            self::checkWindowsPhone($os, $userAgent) ||
            self::checkFreeBSD($os, $userAgent) ||
            self::checkOpenBSD($os, $userAgent) ||
            self::checkNetBSD($os, $userAgent) ||
            self::checkOpenSolaris($os, $userAgent) ||
            self::checkSunOS($os, $userAgent) ||
            self::checkOS2($os, $userAgent) ||
            self::checkBeOS($os, $userAgent) ||
            // Android before Linux
            self::checkAndroid($os, $userAgent) ||
            self::checkLinux($os, $userAgent) ||
            self::checkNokia($os, $userAgent) ||
            self::checkBlackBerry($os, $userAgent)
        );
    }
780993
public function applyRecoveryMatch($userAgent)
    {
        $tolerance = Utils::indexOfOrLength($userAgent, '/', strpos($userAgent, 'Samsung'));

        return $this->getDeviceIDFromRIS($userAgent, $tolerance);
    }
1111838
public function applyConclusiveMatch($userAgent) {
		$deviceId = WURFL_Constants::GENERIC;
		if (WURFL_Handlers_Utils::checkIfStartsWith($userAgent, 'Mozilla')) {
			$deviceId = $this->applyMozillaConclusiveMatch($userAgent);
		} else {
			$tolerance = WURFL_Handlers_Utils::firstSlash($userAgent);
			$deviceId = $this->getDeviceIDFromRIS($userAgent, $tolerance);
		}
		
		return $deviceId;
	}
385715
public function applyConclusiveMatch($userAgent)
    {
        if (WURFL_Configuration_ConfigHolder::getWURFLConfig()->isHighPerformance()) {
            //High performance mode
            $tolerance = WURFL_Handlers_Utils::firstCloseParen($userAgent);
            return $this->getDeviceIDFromRIS($userAgent, $tolerance);
        } else {
            //High accuracy mode
            return $this->getDeviceIDFromLD($userAgent, 5);
        }
    }
1189022
public function getDeviceForUserAgent($userAgent)
    {
        if (!isset($userAgent)) {
            $userAgent = '';
        }
        
        $request = $this->_requestFactory->createRequestForUserAgent($userAgent);
        return $this->getDeviceForRequest($request);
    }
621181
public function applyRecoveryMatch($userAgent)
    {
        if (Utils::checkIfContains($userAgent, 'Froyo')) {
            return 'generic_android_ver2_2';
        }

        $androidVersion = self::getAndroidVersion($userAgent);
        $versionString  = str_replace('.', '_', $androidVersion);
        $deviceID       = 'generic_android_ver' . $versionString;

        if ($deviceID === 'generic_android_ver2_0') {
            $deviceID = 'generic_android_ver2';
        }

        if ($deviceID === 'generic_android_ver4_0') {
            $deviceID = 'generic_android_ver4';
        }

        if (($androidVersion < 3.0 || $androidVersion >= 4.0) && Utils::checkIfContains(
            $userAgent,
            'Safari'
        ) && !Utils::checkIfContains($userAgent, 'Mobile')
        ) {
            // This is probably a tablet (Android 3.x is always a tablet, so it doesn't have a '_tablet' ID)
            if (in_array($deviceID . '_tablet', self::$constantIDs)) {
                return $deviceID . '_tablet';
            }

            return 'generic_android_ver1_5_tablet';
        }

        if (in_array($deviceID, self::$constantIDs)) {
            return $deviceID;
        }

        return 'generic_android';
    }
301204
public function applyConclusiveMatch($userAgent)
    {
        if (Utils::checkIfStartsWithAnyOf($userAgent, array('SEC-', 'SAMSUNG-', 'SCH'))) {
            $tolerance = Utils::firstSlash($userAgent);
        } else {
            if (Utils::checkIfStartsWithAnyOf($userAgent, array('Samsung', 'SPH', 'SGH'))) {
                $tolerance = Utils::firstSpace($userAgent);
            } else {
                $tolerance = Utils::secondSlash($userAgent);
            }
        }

        return $this->getDeviceIDFromRIS($userAgent, $tolerance);
    }
1169374
public function applyConclusiveMatch($userAgent)
    {
        $idx = strpos($userAgent, 'MobilePhone');
        if ($idx !== false) {
            $tolerance = Utils::indexOfOrLength($userAgent, '/', $idx);
        } else {
            $tolerance = Utils::firstSlash($userAgent);
        }

        return $this->getDeviceIDFromRIS($userAgent, $tolerance);
    }