Determine if the user's browser is on a mobile device.

@param Os $os
@param UserAgent $userAgent

@return bool
423927
public static function checkMobileBrowsers(Os $os, UserAgent $userAgent)
    {
        // Check for Opera Mini
        if (stripos($userAgent->getUserAgentString(), 'opera mini') !== false) {
            $os->setIsMobile(true);
        } // Set is mobile for Pocket IE
        elseif (stripos($userAgent->getUserAgentString(), 'mspie') !== false ||
            stripos($userAgent->getUserAgentString(), 'pocket') !== false) {
            $os->setIsMobile(true);
        }
    }
1167292
private static function checkIphone(Device $device, UserAgent $userAgent)
    {
        if (stripos($userAgent->getUserAgentString(), 'iphone;') !== false) {
            $device->setName(Device::IPHONE);
            return true;
        }

        return false;
    }
659988
public function setUserAgent($userAgent = null)
    {
        if (!empty($userAgent)) {
            $this->userAgent = $userAgent;
        } else {
            $this->userAgent = $this->getHttpHeader('User-Agent');

            if (empty($this->userAgent)) {
                $this->userAgent = $this->getHttpHeader('X-Device-User-Agent');
            }

            //Header can occur on devices using Opera Mini (can expose the real device type).
            //Let's concatenate it (we need this extra info in the regexes).
            if ($operaMiniUa = $this->getHttpHeader('X-OperaMini-Phone-UA')) {
                $this->userAgent .= ' ' . $operaMiniUa;
            }
        }
    }
520600
public function device($userAgent = null)
    {
        $rules = static::mergeRules(
            static::getDesktopDevices(),
            static::getPhoneDevices(),
            static::getTabletDevices(),
            static::getUtilities()
        );

        return $this->findDetectionRulesAgainstUA($rules, $userAgent);
    }
829227
public function isDesktopDevice(string $useragent): bool
    {
        if (preg_match('/windows ?(phone|iot|mobile|ce)|iemobile|lumia|xblwp7|zunewp7|wpdesktop|mobile version|microsoft windows; ppc| wds |wpos:|netgem/i', $useragent)) {
            return false;
        }

        // windows
        if (preg_match('/davclnt|revolt|microsoft outlook|wmplayer|lavf|nsplayer|windows|win(10|8|7|vista|xp|2000|98|95|nt|3[12]|me|9x)|barca|cygwin|the bat!/i', $useragent)) {
            return true;
        }

        // linux
        if (preg_match('/linux|debian|ubuntu|cros|tinybrowser/i', $useragent)) {
            return true;
        }

        // macOS
        if (preg_match('/macintosh|darwin|mac(_powerpc|book|mini|pro)|(for|ppc) mac|mac ?os|integrity|camino|pubsub|(os\=|i|power)mac/i', $useragent)) {
            return true;
        }

        if (preg_match('/freebsd|openbsd|netbsd|bsd four|os\/2|warp|sunos|hp-?ux|beos|irix|solaris|openvms|aix|esx|unix|w3m|google desktop|eeepc|dillo|konqueror|eudora|masking-agent|safersurf|integrity|davclnt|cybeye|google pp default|microsoft office|nsplayer|ms ?frontpage|revolt|akregator|installatron|lynx|camino|osf1|barca|the bat!|libvlc|openvas|gvfs/i', $useragent)) {
            return true;
        }

        return false;
    }
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;
    }
1269061
protected function detectEngine($userAgent)
	{
		if (stripos($userAgent, 'MSIE') !== false || stripos($userAgent, 'Trident') !== false)
		{
			// Attempt to detect the client engine -- starting with the most popular ... for now.
			$this->engine = self::TRIDENT;
		}
		elseif (stripos($userAgent, 'AppleWebKit') !== false || stripos($userAgent, 'blackberry') !== false)
		{
			// Evidently blackberry uses WebKit and doesn't necessarily report it.  Bad RIM.
			$this->engine = self::WEBKIT;
		}
		elseif (stripos($userAgent, 'Gecko') !== false && stripos($userAgent, 'like Gecko') === false)
		{
			// We have to check for like Gecko because some other browsers spoof Gecko.
			$this->engine = self::GECKO;
		}
		elseif (stripos($userAgent, 'Opera') !== false || stripos($userAgent, 'Presto') !== false)
		{
			// Sometimes Opera browsers don't say Presto.
			$this->engine = self::PRESTO;
		}
		elseif (stripos($userAgent, 'KHTML') !== false)
		{
			// *sigh*
			$this->engine = self::KHTML;
		}
		elseif (stripos($userAgent, 'Amaya') !== false)
		{
			// Lesser known engine but it finishes off the major list from Wikipedia :-)
			$this->engine = self::AMAYA;
		}

		// Mark this detection routine as run.
		$this->detection['engine'] = true;
	}
640099
private static function checkBlackBerry(Os $os, UserAgent $userAgent)
    {
        if (stripos($userAgent->getUserAgentString(), 'BlackBerry') !== false) {
            if (stripos($userAgent->getUserAgentString(), 'Version/') !== false) {
                $aresult = explode('Version/', $userAgent->getUserAgentString());
                if (isset($aresult[1])) {
                    $aversion = explode(' ', $aresult[1]);
                    $os->setVersion($aversion[0]);
                }
            } else {
                $os->setVersion($os::VERSION_UNKNOWN);
            }
            $os->setName($os::BLACKBERRY);
            $os->setIsMobile(true);

            return true;
        } elseif (stripos($userAgent->getUserAgentString(), 'BB10') !== false) {
            $aresult = explode('Version/10.', $userAgent->getUserAgentString());
            if (isset($aresult[1])) {
                $aversion = explode(' ', $aresult[1]);
                $os->setVersion('10.' . $aversion[0]);
            } else {
                $os->setVersion('10');
            }
            $os->setName($os::BLACKBERRY);
            $os->setIsMobile(true);

            return true;
        }

        return false;
    }
495817
function DetectFirefoxOSPhone()
   {
   	  //First, let's make sure we're NOT on another major mobile OS.
   	  if ($this->DetectIos() == $this->true 
   	  	|| $this->DetectAndroid() == $this->true
   	  	|| $this->DetectSailfish() == $this->true)
         return $this->false;    	  
   
      if ((stripos($this->useragent, $this->engineFirefox) > -1) &&
		(stripos($this->useragent, $this->mobile) > -1))
         return $this->true;
            
      return $this->false; 
   }
1026487
private static function checkOpenBSD(Os $os, UserAgent $userAgent)
    {
        if (stripos($userAgent->getUserAgentString(), 'OpenBSD') !== false) {
            $os->setVersion($os::VERSION_UNKNOWN);
            $os->setName($os::OPENBSD);

            return true;
        }

        return false;
    }
314273
protected function detectEngine($userAgent)
	{
		if (stripos($userAgent, 'MSIE') !== false || stripos($userAgent, 'Trident') !== false)
		{
			// Attempt to detect the client engine -- starting with the most popular ... for now.
			$this->engine = self::TRIDENT;
		}
		elseif (stripos($userAgent, 'Edge') !== false || stripos($userAgent, 'EdgeHTML') !== false)
		{
			$this->engine = self::EDGE;
		}
		elseif (stripos($userAgent, 'Edg') !== false)
		{
			$this->engine = self::BLINK;
		}
		elseif (stripos($userAgent, 'Chrome') !== false)
		{
			$result  = explode('/', stristr($userAgent, 'Chrome'));
			$version = explode(' ', $result[1]);

			if ($version[0] >= 28)
			{
				$this->engine = self::BLINK;
			}
			else
			{
				$this->engine = self::WEBKIT;
			}
		}
		elseif (stripos($userAgent, 'AppleWebKit') !== false || stripos($userAgent, 'blackberry') !== false)
		{
			if (stripos($userAgent, 'AppleWebKit') !== false)
			{
				$result  = explode('/', stristr($userAgent, 'AppleWebKit'));
				$version = explode(' ', $result[1]);

				if ($version[0] === 537.36)
				{
					// AppleWebKit/537.36 is Blink engine specific, exception is Blink emulated IEMobile, Trident or Edge
					$this->engine = self::BLINK;
				}
			}

			// Evidently blackberry uses WebKit and doesn't necessarily report it.  Bad RIM.
			$this->engine = self::WEBKIT;
		}
		elseif (stripos($userAgent, 'Gecko') !== false && stripos($userAgent, 'like Gecko') === false)
		{
			// We have to check for like Gecko because some other browsers spoof Gecko.
			$this->engine = self::GECKO;
		}
		elseif (stripos($userAgent, 'Opera') !== false || stripos($userAgent, 'Presto') !== false)
		{
			$version = false;

			if (preg_match('/Opera[\/| ]?([0-9.]+)/u', $userAgent, $match))
			{
				$version = \floatval($match[1]);
			}

			if (preg_match('/Version\/([0-9.]+)/u', $userAgent, $match))
			{
				if (\floatval($match[1]) >= 10)
				{
					$version = \floatval($match[1]);
				}
			}

			if ($version !== false && $version >= 15)
			{
				$this->engine = self::BLINK;
			}
			else
			{
				$this->engine = self::PRESTO;
			}
		}
		elseif (stripos($userAgent, 'KHTML') !== false)
		{
			// *sigh*
			$this->engine = self::KHTML;
		}
		elseif (stripos($userAgent, 'Amaya') !== false)
		{
			// Lesser known engine but it finishes off the major list from Wikipedia :-)
			$this->engine = self::AMAYA;
		}

		// Mark this detection routine as run.
		$this->detection['engine'] = true;
	}
497276
def detect_firefox_o_s_phone()

      if (detect_ios() || detect_android() || detect_sailfish())
        return false
      end

      if ((user_agent.include?(ENGINE_FIREFOX)) && (user_agent.include?(MOBILE)))
        return true
      end

      return false
    end
720782
protected function detectEngine($userAgent)
    {
        if (stripos($userAgent, 'MSIE') !== false || stripos($userAgent, 'Trident') !== false) {
            // Attempt to detect the client engine -- starting with the most popular ... for now.
            $this->engine = self::ENGINE_TRIDENT;
        } elseif (stripos($userAgent, 'Edge') !== false) {
            $this->engine = self::ENGINE_EDGE_HTML;
        } elseif (stripos($userAgent, 'Edg') !== false) {
            $this->engine = self::ENGINE_BLINK;
        } elseif (stripos($userAgent, 'AppleWebKit') !== false || stripos($userAgent, 'blackberry') !== false) {
            // Evidently blackberry uses WebKit and doesn't necessarily report it.  Bad RIM.
            $this->engine = self::ENGINE_WEBKIT;
        } elseif (stripos($userAgent, 'Chrome') !== false) {
            $result  = explode('/', stristr($userAgent, 'Chrome'));
            $version = explode(' ', $result[1]);

            if ($version[0] >= 28) {
                $this->engine = self::ENGINE_BLINK;
            } else {
                $this->engine = self::ENGINE_WEBKIT;
            }
        } elseif (stripos($userAgent, 'Gecko') !== false && stripos($userAgent, 'like Gecko') === false) {
            // We have to check for like Gecko because some other browsers spoof Gecko.
            $this->engine = self::ENGINE_GECKO;
        } elseif (stripos($userAgent, 'Opera') !== false || stripos($userAgent, 'Presto') !== false) {
            // Sometimes Opera browsers don't say Presto.
            $this->engine = self::ENGINE_PRESTO;
        } elseif (stripos($userAgent, 'KHTML') !== false) {
            // *sigh*
            $this->engine = self::ENGINE_KHTML;
        } elseif (stripos($userAgent, 'Amaya') !== false) {
            // Lesser known engine but it finishes off the major list from Wikipedia :-)
            $this->engine = self::AMAYA;
        }

        // Mark this detection routine as run.
        $this->detection['engine'] = true;
    }
748623
public function canHandle($userAgent)
    {
        if (Utils::isDesktopBrowser($userAgent)) {
            return false;
        }

        return Utils::checkIfContainsCaseInsensitive($userAgent, 'samsung')
            || Utils::checkIfStartsWithAnyOf($userAgent, array('SEC-', 'SPH', 'SGH', 'SCH'));
    }
1203502
private static function checkSunOS(Os $os, UserAgent $userAgent)
    {
        if (stripos($userAgent->getUserAgentString(), 'SunOS') !== false) {
            $os->setVersion($os::VERSION_UNKNOWN);
            $os->setName($os::SUNOS);

            return true;
        }

        return false;
    }
289367
def detectAndroid(self):
        
        if UAgentInfo.deviceAndroid in self.__userAgent \
           or self.detectGoogleTV():
            return True

        return False
824268
def detectFirefoxOSPhone(self):
        
        if self.detectIos() \
            or self.detectAndroid() \
            or self.detectSailfish():
            return False

        if UAgentInfo.engineFirefox in self.__userAgent \
           and UAgentInfo.mobile in self.__userAgent:
            return True

        return False