Determine if the user's operating system is FreeBSD.

@param Os $os
@param UserAgent $userAgent

@return bool
326301
private static function checkFreeBSD(Os $os, UserAgent $userAgent)
    {
        if (stripos($userAgent->getUserAgentString(), 'FreeBSD') !== false) {
            $os->setVersion($os::VERSION_UNKNOWN);
            $os->setName($os::FREEBSD);

            return true;
        }

        return false;
    }
242599
private static function checkBeOS(Os $os, UserAgent $userAgent)
    {
        if (stripos($userAgent->getUserAgentString(), 'BeOS') !== false) {
            $os->setVersion($os::VERSION_UNKNOWN);
            $os->setName($os::BEOS);

            return true;
        }

        return false;
    }
1189022
public function getDeviceForUserAgent($userAgent)
    {
        if (!isset($userAgent)) {
            $userAgent = '';
        }
        
        $request = $this->_requestFactory->createRequestForUserAgent($userAgent);
        return $this->getDeviceForRequest($request);
    }
72022
protected function detectPlatform($userAgent)
	{
		// Attempt to detect the client platform.
		if (stripos($userAgent, 'Windows') !== false)
		{
			$this->platform = self::WINDOWS;

			// Let's look at the specific mobile options in the Windows space.
			if (stripos($userAgent, 'Windows Phone') !== false)
			{
				$this->mobile   = true;
				$this->platform = self::WINDOWS_PHONE;
			}
			elseif (stripos($userAgent, 'Windows CE') !== false)
			{
				$this->mobile   = true;
				$this->platform = self::WINDOWS_CE;
			}
		}
		elseif (stripos($userAgent, 'iPhone') !== false)
		{
			// Interestingly 'iPhone' is present in all iOS devices so far including iPad and iPods.
			$this->mobile   = true;
			$this->platform = self::IPHONE;

			// Let's look at the specific mobile options in the iOS space.
			if (stripos($userAgent, 'iPad') !== false)
			{
				$this->platform = self::IPAD;
			}
			elseif (stripos($userAgent, 'iPod') !== false)
			{
				$this->platform = self::IPOD;
			}
		}
		elseif (stripos($userAgent, 'iPad') !== false)
		{
			// In case where iPhone is not mentioed in iPad user agent string
			$this->mobile   = true;
			$this->platform = self::IPAD;
		}
		elseif (stripos($userAgent, 'iPod') !== false)
		{
			// In case where iPhone is not mentioed in iPod user agent string
			$this->mobile   = true;
			$this->platform = self::IPOD;
		}
		elseif (preg_match('/macintosh|mac os x/i', $userAgent))
		{
			// This has to come after the iPhone check because mac strings are also present in iOS devices.
			$this->platform = self::MAC;
		}
		elseif (stripos($userAgent, 'Blackberry') !== false)
		{
			$this->mobile   = true;
			$this->platform = self::BLACKBERRY;
		}
		elseif (stripos($userAgent, 'Android') !== false)
		{
			$this->mobile   = true;
			$this->platform = self::ANDROID;
			/**
			 * Attempt to distinguish between Android phones and tablets
			 * There is no totally foolproof method but certain rules almost always hold
			 *   Android 3.x is only used for tablets
			 *   Some devices and browsers encourage users to change their UA string to include Tablet.
			 *   Google encourages manufacturers to exclude the string Mobile from tablet device UA strings.
			 *   In some modes Kindle Android devices include the string Mobile but they include the string Silk.
			 */
			if (stripos($userAgent, 'Android 3') !== false || stripos($userAgent, 'Tablet') !== false
				|| stripos($userAgent, 'Mobile') === false || stripos($userAgent, 'Silk') !== false)
			{
				$this->platform = self::ANDROIDTABLET;
			}
		}
		elseif (stripos($userAgent, 'Linux') !== false)
		{
			$this->platform = self::LINUX;
		}

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

        if (Utils::checkIfStartsWith($userAgent, 'Mozilla') === false) {
            return false;
        }

        if (Utils::checkIfContainsAnyOf($userAgent, array('Opera', 'armv', 'MOTO', 'BREW'))) {
            return false;
        }

        // Edge 12 signature
        $hasEdgeMode = Utils::checkIfContains($userAgent, ' Edge/');

        // IE 11 signature
        $hasTridentRv = (Utils::checkIfContains($userAgent, 'Trident') && Utils::checkIfContains($userAgent, 'rv:'));

        // IE < 11 signature
        $hasMsie = Utils::checkIfContains($userAgent, 'MSIE');

        return ($hasMsie || $hasTridentRv || $hasEdgeMode);
    }
1060280
public function detectVersion(string $useragent): VersionInterface
    {
        // lastest version: version on "Goanna" token
        $doMatch = preg_match('/Goanna\/(\d{1,3}\.[\d\.]*)/', $useragent, $matchesFirst);

        if ($doMatch) {
            return (new VersionFactory())->set($matchesFirst[1]);
        }

        // second version: version on "rv:" token
        $doMatch = preg_match('/rv\:(\d\.[\d\.]*)/', $useragent, $matchesSecond);

        if ($doMatch && false !== mb_stripos($useragent, 'goanna')) {
            return (new VersionFactory())->set($matchesSecond[1]);
        }

        // first version: uses gecko version
        return (new VersionFactory())->set('1.0');
    }
473026
public static function isDesktopBrowser($userAgent) {
		if (self::$_is_desktop_browser !== null) return self::$_is_desktop_browser;
		self::$_is_desktop_browser = false;
		$userAgent = strtolower($userAgent);
		foreach (self::$desktopBrowsers as $key) {
			if (strpos($userAgent, $key) !== false) {
				self::$_is_desktop_browser = true;
				break;
			}
		}
		return self::$_is_desktop_browser;
	}
1277430
public static VersionNumber parseOperatingSystemVersion(@Nonnull final OperatingSystemFamily family, @Nonnull final String userAgent) {
		Check.notNull(family, "family");
		Check.notNull(userAgent, "userAgent");

		final VersionNumber v;
		if (OperatingSystemFamily.ANDROID == family) {
			v = identifyAndroidVersion(userAgent);
		} else if (OperatingSystemFamily.BADA == family) {
			v = identifyBadaVersion(userAgent);
		} else if (OperatingSystemFamily.BSD == family) {
			v = identifyBSDVersion(userAgent);
		} else if (OperatingSystemFamily.IOS == family) {
			v = identifyIOSVersion(userAgent);
		} else if (OperatingSystemFamily.JVM == family) {
			v = identifyJavaVersion(userAgent);
		} else if (OperatingSystemFamily.OS_X == family) {
			v = identifyOSXVersion(userAgent);
		} else if (OperatingSystemFamily.SYMBIAN == family) {
			v = identifySymbianVersion(userAgent);
		} else if (OperatingSystemFamily.WEBOS == family) {
			v = identifyWebOSVersion(userAgent);
		} else if (OperatingSystemFamily.WINDOWS == family) {
			v = identifyWindowsVersion(userAgent);
		} else {
			v = VersionNumber.UNKNOWN;
		}
		return v;
	}
953583
public function detectVersion(string $useragent): VersionInterface
    {
        $version = (new Trident())->detectVersion($useragent);

        $versions = [
            '8' => '11.0',
            '7' => '11.0',
            '6' => '10.0',
            '5' => '9.0',
            '4' => '8.0',
        ];

        foreach ($versions as $engineVersion => $ieVersion) {
            if (version_compare($version->getMajor(), (string) $engineVersion, '>=')) {
                return (new VersionFactory())->set($ieVersion);
            }
        }

        $doMatch = preg_match('/MSIE ([\d\.]+)/', $useragent, $matches);

        if ($doMatch) {
            return (new VersionFactory())->set($matches[1]);
        }

        return (new VersionFactory())->set('0');
    }
538597
def is_bsd(name=None):
        
        name = name or sys.platform
        return Platform.is_darwin(name) or Platform.is_freebsd(name)
298321
public function isDesktop($userAgent = null, $httpHeaders = null)
    {
        return !$this->isMobile($userAgent, $httpHeaders) && !$this->isTablet($userAgent, $httpHeaders) && !$this->isRobot($userAgent);
    }
611731
private static OS parseOS(String userAgentString) {
		for (OS os : OS.oses) {
			if (os.isMatch(userAgentString)) {
				return os;
			}
		}
		return OS.Unknown;
	}
907463
public function detectVersion(string $useragent): VersionInterface
    {
        if (false !== mb_stripos($useragent, 'android 2.1-update1')) {
            return (new VersionFactory())->set('2.1.1');
        }

        $search = [
            'android android',
            'android androidhouse team',
            'android wildpuzzlerom v8 froyo',
            'juc ?\(linux;',
            'linux; googletv',
            'android ouya',
            'android os',
            'andr[0o]id[;_ ]',
            'andr[0o]id\/',
            'andr[0o]id',
            'adr ',
            '\(os: ',
        ];

        $detectedVersion = (new VersionFactory())->detectVersion($useragent, $search);

        if ('0.0.0' !== $detectedVersion->getVersion()) {
            return $detectedVersion;
        }

        if (preg_match('/Linux; (\d+[\d\.]+)/', $useragent, $matches)) {
            return (new VersionFactory())->set($matches[1]);
        }

        if (false !== mb_stripos($useragent, 'gingerbread')) {
            return (new VersionFactory())->set('2.3.0');
        }

        if (false !== mb_stripos($useragent, 'android eclair')) {
            return (new VersionFactory())->set('2.1.0');
        }

        return new Version('0');
    }
544364
public static function isDesktopBrowser($userAgent)
    {
        if (self::$isDesktopBrowser !== null) {
            return self::$isDesktopBrowser;
        }

        self::$isDesktopBrowser = false;
        $userAgent              = strtolower($userAgent);

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

        return self::$isDesktopBrowser;
    }
127303
public function platform($userAgent = null)
    {
        // Get platform rules
        $rules = $this->mergeRules(
            static::$operatingSystems,
            static::$additionalOperatingSystems // NEW
        );

        return $this->findDetectionRulesAgainstUA($rules, $userAgent);
    }
864353
public function detectVersion(string $useragent): VersionInterface
    {
        if (false !== mb_strpos($useragent, 'MyIE2')) {
            return (new VersionFactory())->set('2.0');
        }

        if (false !== mb_strpos($useragent, 'MyIE')) {
            $versionFactory = new VersionFactory('/^v?(?<major>\d+)(?:[-|\.](?<minor>\d+))?(?:[-|\.](?<micro>\d+))?(?:[-|\.](?<patch>\d+))?(?:[-|\.](?<micropatch>\d+))?(?:[-_.+ ]?(?<stability>rc|alpha|a|beta|b|patch|pl?|stable|dev|d)[-_.+ ]?(?<build>\d*))?.*$/i');

            return $versionFactory->detectVersion($useragent, ['MyIE']);
        }

        return (new VersionFactory())->detectVersion($useragent, ['MxBrowser\\-iPhone', 'Maxthon', 'MxBrowser', 'Version']);
    }
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));
		}
	}