Get the current instance of the api-wrapper or create a new one.
@param string $useragent The name of the wrappers-useragent.
@return SpigetAPI
546772
public static function getInstance( $useragent = 'Spiget4PHP' )
    {
        if (is_null(SpigetAPI::$instance)) {
            SpigetAPI::$instance = new SpigetAPI($useragent);
        }
        return SpigetAPI::$instance;
    }
182648
public function robot($userAgent = null)
    {
        if ($this->getCrawlerDetect()->isCrawler($userAgent ?: $this->userAgent)) {
            return ucfirst($this->getCrawlerDetect()->getMatches());
        }

        return false;
    }
1021165
public function applyConclusiveMatch($userAgent)
    {
        //High accuracy mode
        $tolerance = Utils::firstCloseParen($userAgent);

        return $this->getDeviceIDFromRIS($userAgent, $tolerance);
    }
764768
public function device($userAgent = null)
    {
        // Get device rules
        $rules = $this->mergeRules(
            static::$additionalDevices, // NEW
            static::$phoneDevices,
            static::$tabletDevices,
            static::$utilities
        );

        return $this->findDetectionRulesAgainstUA($rules, $userAgent);
    }
398927
public function detectVersion(string $useragent): VersionInterface
    {
        if (preg_match('/xblwp7|zunewp7/i', $useragent)) {
            return (new VersionFactory())->set('7.5.0');
        }

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

        if (preg_match('/wpdesktop/i', $useragent)) {
            if (preg_match('/windows nt 6\.3/i', $useragent)) {
                return (new VersionFactory())->set('8.1.0');
            }

            if (preg_match('/windows nt 6\.2/i', $useragent)) {
                return (new VersionFactory())->set('8.0.0');
            }

            return (new VersionFactory())->set('0');
        }

        $searches = ['Windows Phone OS', 'Windows Phone', 'Windows Mobile', 'Windows NT', 'WPOS\:'];

        return (new VersionFactory())->detectVersion($useragent, $searches);
    }
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');
    }
1372328
public function detectVersion(string $useragent): VersionInterface
    {
        if (preg_match('/raspbian\/([\d\.]+)/i', $useragent, $matches)) {
            return (new VersionFactory())->set($matches[1]);
        }

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

        return (new VersionFactory())->set('0');
    }
968430
public static function getHTCMacModel($userAgent)
    {
        if (preg_match('/(HTC[^;\)]+)/', $userAgent, $matches)) {
            $model = preg_replace('#[ _\-/]#', '~', $matches[1]);

            return $model;
        }

        return null;
    }
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';
    }
554494
public function normalize($userAgent)
    {
        $model = HTCMacHandler::getHTCMacModel($userAgent, false);

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

            return $prefix . $userAgent;
        }

        return $userAgent;
    }
556562
public function getUserAgent()
    {
        if ($this->USER_AGENT) {
            return $this->USER_AGENT;
        }

        if ($this->HTTP_USER_AGENT) {
            return $this->HTTP_USER_AGENT;
        }

        return null;
    }
674474
public function getBrowser(string $userAgent = null)
    {
        // Check if an automatic update is required
        $this->autoUpdate();

        // If no user agent is set, try to get it from the HTTP headers
        if ($userAgent === null) {
            $userAgent = $_SERVER['HTTP_USER_AGENT'] ?? '';
        }

        // Get rwa Browscap data and return a formatted version, using the set Formatter
        $browscapData = $this->getParser()->getReader()->getBrowser($userAgent);
        return $this->getFormatter()->format($browscapData);
    }
838287
public function createRequestFromString(string $userAgent): GenericRequest
    {
        if (!HeaderSecurity::isValid($userAgent)) {
            $userAgent = $this->filterHeader($userAgent);
        }

        $message = ServerRequestFactory::fromGlobals([Constants::HEADER_HTTP_USERAGENT => $userAgent]);

        return $this->createRequestFromPsr7Message($message);
    }
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;
    }
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;
    }
528926
public function setUserAgent($userAgent) {
		$this->userAgent = $userAgent;
		$this->removeHeader(self::HEADER_KEY_USER_AGENT);
		$this->addHeader(self::HEADER_KEY_USER_AGENT, $userAgent);
		return $this;
	}
273019
public function setUserAgent($userAgent = null)
        {
            if (!empty($userAgent)) {
                return $this->userAgent = $userAgent;
            } else {
                $this->userAgent = null;
                foreach($this->getUaHttpHeaders() as $altHeader) {
                    if(!empty($this->httpHeaders[$altHeader])) { // @todo: should use getHttpHeader(), but it would be slow. (Serban)
                        $this->userAgent .= $this->httpHeaders[$altHeader] . " ";
                    }
                }
                return $this->userAgent = (!empty($this->userAgent) ? trim($this->userAgent) : null);
            }
        }