ning Java ME are more likely a features phones */ if ('Java ME' === $osName && null === $this->device) { $this->device = AbstractDeviceParser::DEVICE_TYPE_FEATURE_PHONE; } /** * According to http://msdn.microsoft.com/en-us/library/ie/hh920767(v=vs.85).aspx * Internet Explorer 10 introduces the "Touch" UA string token. If this token is present at the end of the * UA string, the computer has touch capability, and is running Windows 8 (or later). * This UA string will be transmitted on a touch-enabled system running Windows 8 (RT) * * As most touch enabled devices are tablets and only a smaller part are desktops/notebooks we assume that * all Windows 8 touch devices are tablets. */ if (null === $this->device && ('Windows RT' === $osName || ('Windows' === $osName && \version_compare($osVersion, '8') >= 0)) && $this->isTouchEnabled() ) { $this->device = AbstractDeviceParser::DEVICE_TYPE_TABLET; } /** * All devices running Puffin Secure Browser that contain letter 'D' are assumed to be desktops */ if (null === $this->device && $this->matchUserAgent('Puffin/(?:\d+[.\d]+)[LMW]D')) { $this->device = AbstractDeviceParser::DEVICE_TYPE_DESKTOP; } /** * All devices running Puffin Web Browser that contain letter 'P' are assumed to be smartphones */ if (null === $this->device && $this->matchUserAgent('Puffin/(?:\d+[.\d]+)[AIFLW]P')) { $this->device = AbstractDeviceParser::DEVICE_TYPE_SMARTPHONE; } /** * All devices running Puffin Web Browser that contain letter 'T' are assumed to be tablets */ if (null === $this->device && $this->matchUserAgent('Puffin/(?:\d+[.\d]+)[AILW]T')) { $this->device = AbstractDeviceParser::DEVICE_TYPE_TABLET; } /** * All devices running Opera TV Store are assumed to be a tv */ if ($this->matchUserAgent('Opera TV Store| OMI/')) { $this->device = AbstractDeviceParser::DEVICE_TYPE_TV; } /** * All devices that contain Andr0id in string are assumed to be a tv */ if ($this->matchUserAgent('Andr0id|(?:Android(?: UHD)?|Google) TV|\(lite\) TV|BRAVIA| TV$')) { $this->device = AbstractDeviceParser::DEVICE_TYPE_TV; } /** * All devices running Tizen TV or SmartTV are assumed to be a tv */ if (null === $this->device && $this->matchUserAgent('SmartTV|Tizen.+ TV .+$')) { $this->device = AbstractDeviceParser::DEVICE_TYPE_TV; } /** * Devices running those clients are assumed to be a TV */ if (\in_array($clientName, [ 'Kylo', 'Espial TV Browser', 'LUJO TV Browser', 'LogicUI TV Browser', 'Open TV Browser', 'Seraphic Sraf', 'Opera Devices', 'Crow Browser', 'Vewd Browser', 'TiviMate', 'Quick Search TV', 'QJY TV Browser', 'TV Bro', ]) ) { $this->device = AbstractDeviceParser::DEVICE_TYPE_TV; } /** * All devices containing TV fragment are assumed to be a tv */ if (null === $this->device && $this->matchUserAgent('\(TV;')) { $this->device = AbstractDeviceParser::DEVICE_TYPE_TV; } /** * Set device type desktop if string ua contains desktop */ $hasDesktop = AbstractDeviceParser::DEVICE_TYPE_DESKTOP !== $this->device && false !== \strpos($this->userAgent, 'Desktop') && $this->hasDesktopFragment(); if ($hasDesktop) { $this->device = AbstractDeviceParser::DEVICE_TYPE_DESKTOP; } // set device type to desktop for all devices running a desktop os that were not detected as another device type if (null !== $this->device || !$this->isDesktop()) { return; } $this->device = AbstractDeviceParser::DEVICE_TYPE_DESKTOP; } /** * Tries to detect the operating system */ protected function parseOs(): void { $osParser = new OperatingSystem(); $osParser->setUserAgent($this->getUserAgent()); $osParser->setClientHints($this->getClientHints()); $osParser->setYamlParser($this->getYamlParser()); $osParser->setCache($this->getCache()); $this->os = $osParser->parse(); } /** * @param string $regex * * @return array|null */ protected function matchUserAgent(string $regex): ?array { $regex = '/(?:^|[^A-Z_-])(?:' . \str_replace('/', '\/', $regex) . ')/i'; if (\preg_match($regex, $this->userAgent, $matches)) { return $matches; } return null; } /** * Resets all detected data */ protected function reset(): void { $this->bot = null; $this->client = null; $this->device = null; $this->os = null; $this->brand = ''; $this->model = ''; $this->parsed = false; } }