@param $device

@return \a15lam\PhpWemo\WemoClient
432313
protected static function getClientByDevice($device)
    {
        $ip = static::getIpFromDevice($device);
        $port = static::getPortFromDevice($device);
        $client = new WemoClient($ip, $port);

        return $client;
    }
190520
public function removeDevice(\Sopinet\ChatBundle\Entity\Device $device)
    {
        $this->devices->removeElement($device);
    }
1300160
public function getDevice($deviceId)
    {
        if (!isset($this->deviceCache[$deviceId])) {
            $device = $this->persistenceStorage->load($deviceId);

            if (!$device) {
                throw new \InvalidArgumentException(
                    'There is no device with ID [' . $deviceId . '] in the loaded WURFL Data'
                );
            }

            $this->deviceCache[$deviceId] = $device;
        }

        return $this->deviceCache[$deviceId];
    }
1257520
public function getDeviceState($deviceName)
    {
        $uri = "deviceStates/$deviceName";
        $response = $this->client->getEndpoint()->get($uri);

        return new DeviceState($this->client, \GuzzleHttp\json_decode($response->getBody()));
    }
1161807
public DeviceEnvelope addDevice(Device device) throws ApiException {
        ApiResponse<DeviceEnvelope> resp = addDeviceWithHttpInfo(device);
        return resp.getData();
    }
78261
public function activate(Model\InStore\Device $device, HandlerStack $stack = null)
    {
        try {
            $params = [
                'headers' => [
                    'Accept' => 'application/json',
                    'Content-Type' => 'application/json',
                ],
                'body' => $this->getSerializer()->serialize(
                    $device,
                    'json',
                    SerializationContext::create()->setGroups(['activateDevice'])
                ),
            ];
            if ($stack !== null) {
                $params['handler'] = $stack;
            }

            $result = $this->getClient()->post('devices/activate', $params);

            return $this->getSerializer()->deserialize(
                (string) $result->getBody(),
                Model\InStore\Device::class,
                'json'
            );
        } catch (BadResponseException $e) {
            throw new ApiException(
                $this->getSerializer()->deserialize(
                    (string) $e->getResponse()->getBody(),
                    Model\ErrorResponse::class,
                    'json'
                ),
                $e
            );
        }
    }
1156504
public function upgrade_device($device_mac)
    {
        if (!$this->is_loggedin) {
            return false;
        }

        $payload  = ['mac' => strtolower($device_mac)];
        $response = $this->exec_curl('/api/s/' . $this->site . '/cmd/devmgr/upgrade', $payload);

        return $this->process_response_boolean($response);
    }
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;
    }
1276411
public function setFromDevice(\Sopinet\ChatBundle\Entity\Device $fromDevice = null)
    {
        $this->fromDevice = $fromDevice;

        return $this;
    }
520600
public function device($userAgent = null)
    {
        $rules = static::mergeRules(
            static::getDesktopDevices(),
            static::getPhoneDevices(),
            static::getTabletDevices(),
            static::getUtilities()
        );

        return $this->findDetectionRulesAgainstUA($rules, $userAgent);
    }
312480
private function getClientBrowser(\DeviceDetector\DeviceDetector $deviceDetectorClass, $userAgent)
    {
        $this->autoPopulateSuperGlobals();
        $browserInfoArray   = [
            'architecture' => $this->getArchitectureFromUserAgent($userAgent, 'browser'),
            'connection'   => $this->brServerGlobals->server->get('HTTP_CONNECTION'),
            'family'       => $this->getClientBrowserFamily($deviceDetectorClass),
            'host'         => $this->brServerGlobals->server->get('HTTP_HOST'),
            'referrer'     => $this->brServerGlobals->headers->get('referer'),
            'user_agent'   => $this->getUserAgentByCommonLib(),
        ];
        $vrs                = $this->getClientBrowserVersion($deviceDetectorClass);
        $browserInformation = array_merge($browserInfoArray, $this->getClientBrowserAccepted(), $vrs);
        ksort($browserInformation);
        return $browserInformation;
    }
154065
public static function get_user_device_type() {
        $device = self::get_device_type();
        $switched = get_user_preferences('switchdevice'.$device, false);
        if ($switched != false) {
            return $switched;
        }
        return $device;
    }
947141
public static function detect(Device $device, UserAgent $userAgent)
    {
        $device->setName($device::UNKNOWN);

        /*iphone，ipad，windowphone*/
        $flag = self::checkIpad($device, $userAgent) ||self::checkIphone($device, $userAgent) || self::checkWindowsPhone($device, $userAgent);
        if( $flag ){
        	return true;
		}
        /*android*/
		if (stripos($userAgent->getUserAgentString(), 'android') !== false) {
			$device->setName(Device::Android);
			foreach (self::$androidList as $androidName ) {
				$funcName = 'check'. $androidName;
				if ( self::$funcName( $device, $userAgent ) ) {
					return true;
				}
			}
		}

		return false;

    }
225979
public function setDevice(\BlackForest\PiwikBundle\Entity\PiwikDevice $device = null)
    {
        $this->device = $device;

        return $this;
    }
547965
private function deviceIdForRequest($request) {
		$deviceId = $this->_cacheProvider->load($request->id);
		if (empty($deviceId)) {
			$deviceId = $this->_userAgentHandlerChain->match($request);
			// save it in cache
			$this->_cacheProvider->save($request->id, $deviceId);
		} else {
			$request->matchInfo->from_cache = true;
			$request->matchInfo->lookup_time = 0.0;
		}
		return $deviceId;
	}
1325731
protected function assignProperties($device)
    {

        //Is UA Windows Mobile?
        if ($device->os->setContains($device->device_ua, 'Windows CE', 'Windows Mobile') && $device->browser->set('IE Mobile')) {
            return $device;
        }

        //Is UA Windows Phone OS? - WP before Android
        if (strpos($device->device_ua, 'Windows Phone') !== false || strpos($device->device_ua, '; wds') !== false) {
            if ($device->os->setRegex($device->device_ua, '/Windows Phone(?: OS)? ([\d\.]+)/', 'Windows Phone', 1) || $device->os->setRegex($device->device_ua, '#UCWEB/\d\.\d \(Windows;.+?; wds ?([\d\.]+?);.+UCBrowser#', 'Windows Phone', 1)) {
                if ($device->browser->setRegex($device->browser_ua, '/UCBrowser\/([\d\.]+)/', 'UC Browser', 1)) {
                    return $device;
                }
                if ($device->browser->setRegex($device->browser_ua, '/IEMobile\/([\d\.]+)/', 'IE Mobile', 1)) {
                    return $device;
                }
                if ($device->browser->setRegex($device->browser_ua, '/Edge\/([\d\.]+)/', 'Edge Mobile', 1)) {
                    return $device;
                }
            }
        }

        //Is UA Android?
        if (strpos($device->device_ua, 'Android') !== false || strpos($device->device_ua, ' Adr ') !== false) {
            $device->os->setRegex($device->device_ua, '#Android(?: |/)([\d\.]+).+#', 'Android', 1);
            $device->os->setRegex($device->device_ua, '# Adr(?: |/)([\d\.]+).+#', 'Android', 1);
            
            //Is Dalvik?
            if (strpos($device->browser_ua, 'Dalvik') !== false) {
                $device->browser->name = 'Android App';
                if ($device->browser->setRegex($device->browser_ua, '/Android ([\d\.]+)/', null, 1)) {
                    return $device;
                }
            }
                        
            //Is FB app?
            if ($device->browser->setRegex($device->browser_ua, '/^Mozilla\/[45]\.0.+?Android.+?AppleWebKit.+FBAN/', 'FaceBook Android App', $device->os->version)) {
                return $device;
            }

            //Is UA Opera?
            if ($device->browser->setRegex($device->browser_ua, '/OPR\/([\d\.]+)/', 'Opera', 1)) {
                return $device;
            }

            //Is 360Browser?
            if (strpos($device->browser_ua, 'Aphone Browser') !== false || strpos($device->browser_ua, '360browser') !== false) {
                $device->browser->set('360 Browser', null);
                return $device;
            }
            
            //Is UA Fennec?
            if ($device->browser->setRegex($device->browser_ua, '/(?:Firefox|Fennec)\/([\d\.]+)/', 'Firefox Mobile', 1)) {
                return $device;
            }
            
            //Is UA Opera Mobi?
            if ($device->browser->setRegex($device->browser_ua, '/Opera Mobi\/.*Version\/([\d\.]+)/', 'Opera Mobile', 1)) {
                return $device;
            }
            
            //Is UA Opera Mini?
            if ($device->browser->setRegex($device->browser_ua, '/Opera Mini\/([\d\.]+)/', 'Opera Mini', 1)) {
                return $device;
            }
            
            //Is UA Opera Tablet?
            if ($device->browser->setRegex($device->browser_ua, '/Opera Tablet\/.*Version\/([\d\.]+)/', 'Opera Tablet', 1)) {
                return $device;
            }
            
            //Is UA UC Browser with UCBrowser tag?
            if ($device->browser->setRegex($device->browser_ua, '/UCBrowser\/([\d\.]+)/', 'UC Browser', 1)) {
                return $device;
            }
            
            //Is UA UC Browser with UCWEB tag?
            if ($device->browser->setRegex($device->browser_ua, '/^JUC.*UCWEB([0-9])/', 'UC Browser', 1)) {
                return $device;
            }
            
            //Is UA Amazon Silk browser?
            if ($device->browser->setRegex($device->browser_ua, '/Silk\/([\d\.]+).+?Silk\-Accelerated/', 'Amazon Silk Browser', 1)) {
                return $device;
            }

            //Is UA Baidu browser?
            if ($device->browser->setRegex($device->browser_ua, '/bdbrowser(?:_i18n)?\/(\d+)/', 'Baidu Browser', 1)) {
                return $device;
            }

            //Is UA Samsung Browser?
            if ($device->browser->setRegex($device->browser_ua, '#SamsungBrowser/([\d\.]+) Chrome/[\d\.]+#', 'Samsung Browser', 1)) {
                return $device;
            }

            //Is UA Chromium?
            if ($device->browser->setRegex($device->browser_ua, '/Version\/.+?Chrome\/([\d\.]+)/', 'Chromium', 1)) {
                return $device;
            }

            //Is UA Chrome Mobile?
            if ($device->browser->setRegex($device->browser_ua, '/Chrome\/([\d\.]+)?/', 'Chrome Mobile', 1)) {
                return $device;
            }

            //Is UA Android Webkit UA
            if ($device->browser->setRegex($device->browser_ua, '/Version\/\d/', 'Android Webkit', $device->os->version)) {
                return $device;
            }

            //Catchall for all other Android UAs
            $device->browser->set('Android', $device->os->version);

            return $device;
        }
        
        //Is UA Amazon Silk browser without the word Android?
        if (strpos($device->device_ua, 'Silk') !== false && $device->browser->setRegex($device->browser_ua, '/Silk\/([\d\.]+).+?Silk\-Accelerated/', 'Amazon Silk Browser', 1)
            && $device->os->set("Android", null)) {
            return $device;
        }
        
        //Is UA iOS?
        if (strpos($device->device_ua_normalized, 'iPhone') !== false || strpos($device->device_ua_normalized, 'iPad') !== false || strpos($device->device_ua_normalized, 'iPod') !== false || strpos($device->device_ua_normalized, '(iOS;') !== false) {
            $device->os->name = 'iOS';

            if ($device->os->setRegex($device->device_ua_normalized, '/Mozilla\/[45]\.0 \((iPhone|iPod|iPad);(?: U;)? CPU(?: iPhone|) OS ([\d_]+) like Mac OS X/', 'iOS', 2)
                || $device->os->setRegex($device->device_ua_normalized, '#^[^/]+?/[\d\.]+? \(i[A-Za-z]+; iOS ([\d\.]+); Scale/[\d\.]+\)#', 'iOS', 1)
                || $device->os->setRegex($device->device_ua_normalized, '#^server-bag \[iPhone OS,([\d\.]+),#', 'iOS', 1)
                || $device->os->setRegex($device->device_ua_normalized, '#^i(?:Phone|Pad|Pod)\d+?,\d+?/([\d\.]+)#', 'iOS', 1)) {
                $device->os->version = str_replace("_", ".", $device->os->version);
            }

            // Get Device OS version for UCBrowser 2K?
            if ($device->os->setRegex($device->device_ua, '#UCWEB/[\d\.]+ \(iOS;.+?OS ([\d_]+);.+UCBrowser/#', 'iOS', 1)) {
                $device->os->version = str_replace("_", ".", $device->os->version);
            }

            //Is UA Chrome Mobile on iOS?
            if ($device->browser->setRegex($device->browser_ua, '/^Mozilla\/[45]\.0.+?like Mac OS X.+?CriOS\/([\d\.]+).+?Mobile\/[0-9A-Za-z]+ Safari\/[0-9A-Za-z]+\./',
                'Chrome Mobile on iOS', 1)) {
                return $device;
            }

            //Is UA Firefox on iOS?
            if ($device->browser->setRegex($device->browser_ua, '/^Mozilla\/[45]\.0.+?like Mac OS X.+?FxiOS\/([\d\.]+).+?Mobile\/[0-9A-Za-z]+ Safari\/[0-9A-Za-z]+\./',
                'Firefox on iOS', 1)) {
                return $device;
            }

            //Is UA Opera Mini on iOS?
            if ($device->browser->setRegex($device->browser_ua, '/^Mozilla\/[45]\.0.+?like Mac OS X.+?OPiOS\/([\d\.]+).+?Mobile\/[0-9A-Za-z]+ Safari\/[0-9A-Za-z]+\./',
                'Opera Mini on iOS', 1)) {
                return $device;
            }

            //Is UA UC Web Browser?
            if ($device->browser->setRegex($device->browser_ua, '/^Mozilla\/[45]\.0.+?OS \d_\d.+?like Mac OS X.+?AppleWebKit.+?.+UCBrowser\/([\d\.]+)/',
                'UC Web Browser on iOS', 1)) {
                return $device;
            }

            // Is UA UC Web Browser 2K?
            if ($device->browser->setRegex($device->browser_ua, '#UCWEB/\d\.\d \(iOS;.+?OS [\d_]+;.+UCBrowser/([\d\.]+)#', 'UC Web Browser on iOS', 1)) {
                return $device;
            }

            //Is UA Facebook on iOS?
            if ($device->browser->setRegex($device->browser_ua, '/^Mozilla\/[45]\.0.+?like Mac OS X.+?AppleWebKit.+?Mobile\/[0-9A-Za-z]+.*FBAN/', 'FaceBook on iOS',
                $device->os->version)) {
                return $device;
            }

            // Is UA iOS Safari?
            if ($device->browser->setRegex($device->browser_ua, '#^Mozilla.+like Mac OS X.+Version/([\d\.]+)#', 'Mobile Safari', 1)) {
                return $device;
            }

            //Catchall for all other iOS UAs including Mobile Safari
            $device->browser->set('Mobile Safari', $device->os->version);

            return $device;
        }
        
        //Is UA S40 Ovi Browser?
        if (strpos($device->device_ua, 'OviBrowser') !== false && $device->browser->setRegex($device->browser_ua, '/\bS40OviBrowser\/([\d\.]+)/', 'S40 Ovi Browser', 1) && $device->os->set('Nokia Series 40')) {
            return $device;
        }
        
        //Is Series60?
        if ($device->os->setRegex($device->device_ua, '#(?:SymbianOS|Series60|S60)/([\d\.]+)#', 'Symbian S60', 1) || $device->os->setRegex($device->device_ua, '#UCWEB/\d\.\d \(Symbian;.+?S60 V(\d+)#', 'Symbian S60', 1)) {
            if ($device->os->setRegex($device->device_ua, '/^Mozilla\/[45]\.0 \(Symbian\/3/', 'Symbian', '^3'));
            
            if ($device->browser->setRegex($device->browser_ua, '/NokiaBrowser\/([\d\.]+)/', 'Symbian S60 Browser', 1)) {
                return $device;
            }

            if ($device->browser->setRegex($device->browser_ua, '/Opera Mobi.+Version\/([\d\.]+)/', 'Opera Mobi', 1)) {
                return $device;
            }

            if ($device->browser->setRegex($device->browser_ua, '#UCWEB/[\d\.]+ \(Symbian;.+?UCBrowser/([\d\.]+)#', 'UC Web Browser on Symbian', 1)) {
                return $device;
            }

            $device->browser->set('Symbian S60 Browser');
            return $device;
        }
        
        //Is UA Blackberry?
        if (strpos($device->device_ua, 'BlackBerry') !== false || strpos($device->device_ua, '(BB10; ') !== false) {
            
            // Set resonable defaults
            $device->os->setRegex($device->device_ua, '/(?:BlackBerry)|(?:^Mozilla\/5.0 \(BB10; )/', 'BlackBerry');
            $device->os->setRegex($device->device_ua, '/^BlackBerry[0-9A-Za-z]+?\/([\d\.]+)/', null, 1);
            
            if ($device->os->setRegex($device->device_ua, '/^BlackBerry[0-9A-Za-z]+?\/([\d\.]+).+?UC Browser\/?([\d\.]+)/', null, 1)) {
                $device->browser->set('UC Web', $device->os->getLastRegexMatch(2));
                return $device;
            }
            
            if ($device->os->setRegex($device->device_ua, '/^UCWEB\/[0-9]\.0.+?; [a-zA-Z][a-zA-Z]?\-[a-zA-Z]?[a-zA-Z]; [0-9]+?\/([\d\.]+).+?UCBrowser\/?([\d\.]+)/', null, 1)) {
                $device->browser->set('UC Web', $device->os->getLastRegexMatch(2));
                return $device;
            }
            
            // Is UA Opera Mini?
            if ($device->browser->setRegex($device->browser_ua, '/Opera Mini\/([\d\.]+)/', 'Opera Mini', 1)) {
                return $device;
            }
            
            if ($device->os->setRegex($device->device_ua, '/^Mozilla\/[45]\.0 \(BlackBerry;(?: U;)? BlackBerry.+?Version\/([\d\.]+)/', null, 1)) {
                $device->browser->set('BlackBerry Browser', $device->os->version);
                return $device;
            }
            
            if ($device->os->setRegex($device->device_ua, '#^Mozilla/[45]\.0 \(BB10; .+?Version/([\d\.]+)#', null, 1)) {
                $device->browser->set('BlackBerry Webkit Browser', $device->os->version);
                return $device;
            }
            
            $device->browser->set('BlackBerry Browser', $device->os->version);

            return $device;
        }
        
        //Is UA RIM Tablet OS?
        if (strpos($device->device_ua, 'RIM Tablet OS') !== false
            && $device->os->setRegex($device->device_ua, '/RIM Tablet OS ([\d\.]+).+?Version\/([\d\.]+)/', 'RIM Tablet OS', 1)) {
            $device->browser->set('RIM OS Browser', $device->os->getLastRegexMatch(2));
            return $device;
        }
        
        //Is UA Netfront?
        if (strpos($device->device_ua, 'NetFront') !== false
            && $device->browser->setRegex($device->browser_ua, '/NetFront\/([\d\.]+)/', 'NetFront', 1)) {
            return $device;
        }
        
        //Is UA Teleca Obigo
        if ($device->browser->setContains($device->device_ua, 'Obigo', 'Teleca Obigo')
            && $device->browser->setRegex($device->browser_ua, '/Obig[a-zA-Z]+?\/(Q[0-9\.ABC]+)/', null, 1)) {
            return $device;
        }
        
        //Is UA Samsung's Bada OS?
        if (strpos($device->device_ua, 'Dolfin') !== false
            && $device->os->setRegex($device->device_ua, '/SAMSUNG.+?\bBada\/([\d\.]+);?.+Dolfin\/([\d\.]+)/', 'Bada', 1)) {
            $device->browser->set('Dolfin Browser', $device->os->getLastRegexMatch(2));
            return $device;
        }
        
        //Is UA a MAUI browser?
        if ($device->browser->setContains($device->device_ua, 'MAUI', 'MAUI Browser')) {
            return $device;
        }
        
        //Is UA an Openwave browser?
        if (strpos($device->device_ua, 'Dolfin') !== false
            && $device->browser->setRegex($device->browser_ua, '/UP\.(?:Browser|Link)\/([\d\.]+)/', 'Openwave Browser', 1)) {
            return $device;
        }
        
        //Is UA webOS?
        if ($device->os->setRegex($device->device_ua, '/^Mozilla\/[45]\.0 \((?:Linux; )?webOS\/([\d\.]+)/', 'webOS', 1)) {
            $device->browser->set('webOS Browser', $device->os->version);
            return $device;
        }
        
        if (strpos($device->device_ua, 'Opera') !== false) {
            //Is UA Opera Mobi?
            if ($device->browser->setContains($device->device_ua, 'Opera Mobi', 'Opera Mobile')) {
                if ($device->browser->setRegex($device->device_ua, '/Opera Mobi.+Version\/([\d\.]+)/', null, 1)) {
                    return $device;
                }
                return $device;
            }
            
            //Is UA Opera Mini?
            if ($device->browser->setRegex($device->device_ua, '/Opera Mini\/([\d\.]+)/', 'Opera Mini', 1)) {
                return $device;
            }
            
            //Is UA Opera Sync?
            if ($device->browser->setRegex($device->device_ua, '/Browser\/Opera Sync\/SyncClient.+?Version\/([\d\.]+)/',
                'Opera Link Sync', 1)) {
                return $device;
            }
        }
        
        if (strpos($device->device_ua, 'Maemo') !== false) {
            $device->os->set('Maemo');
            //Maemo
            if ($device->browser->setRegex($device->browser_ua, '/Maemo.+?Firefox\/([0-9a\.]+) /', 'Firefox', 1)) {
                return $device;
            }
        }

        //UCBrowser on Java devices
        if (strpos($device->device_ua, 'Java') !== false && strpos($device->device_ua, 'UCBrowser/') !== false) {
            if ($device->browser->setRegex($device->browser_ua, '#UCWEB/\d\.\d \(Java;.+?UCBrowser/([\d\.]+)#', 'UCBrowser Java Applet', 1)) {
                return $device;
            }
        }

        //Final ditch effort
        if ($device->browser->setRegex($device->browser_ua, '/(?:MIDP.+?CLDC)|(?:UNTRUSTED)|(?:MIDP-2.0)/', 'Java Applet')) {
            return $device;
        }
        
        
        // Desktop Browsers

        //Baidu browser?
        if ($device->os->setRegex($device->device_ua, '/^Mozilla\/[0-9]\.0 .+?((?:Windows|Linux|PPC|Intel) [a-zA-Z0-9 _\.\-]+).+bdbrowser(?:_i18n)?\/([\d\.]+)/', 1)) {
            $device->browser->set('Baidu Browser', $device->os->getLastRegexMatch(2));
            return $device;
        }

        //360 Browser
        if ((strpos($device->device_ua, '360Browser') !== false || strpos($device->device_ua, ' 360SE') !== false) && $device->os->setRegex($device->device_ua, '/^Mozilla\/[0-9]\.0 .+?((?:Windows|Linux|PPC|Intel) [a-zA-Z0-9 _\.\-]+).+(?:360Browser|360SE)/', 1)) {
            $device->browser->set('360 Browser', null);
            return $device;
        }

        //MSIE - If UA says MSIE
        if (strpos($device->device_ua, 'MSIE') !== false) {
            if ($device->os->setRegex($device->device_ua, '/^Mozilla\/[0-9]\.0 \(compatible; MSIE ([\d\.]+); ((?:Windows NT [0-9]+\.[0-9])|(?:Windows [0-9]\.[0-9])|(?:Windows [0-9]+)|(?:Mac_PowerPC))/', 2)) {
                $device->browser->set('IE', $device->os->getLastRegexMatch(1));
                return $device;
            }
        }

        //MSIE - If UA says Trident - This logic must stay above Chrome
        if (strpos($device->device_ua, 'Trident') !== false || strpos($device->device_ua, ' Edge/') !== false) {
            //MSIE 11 does not say MSIE and needs this
            if ($device->os->setRegex($device->device_ua, '#^Mozilla/[45]\.0 \((Windows NT [\d\.]+);.+Trident.+; rv:([\d\.]+)\.[0-9]+#', 1)) {
                $device->browser->set('IE', $device->os->getLastRegexMatch(2));
                return $device;
            }
            if ($device->os->setRegex($device->device_ua, '#^Mozilla/[45]\.0 \((Windows NT [\d\.]+).+? Edge/([\d\.]+)#', 1)) {
                $device->browser->set('Edge', $device->os->getLastRegexMatch(2));
                return $device;
            }
        }
        
        //Yandex Browser
        if (strpos($device->device_ua, 'YaBrowser') !== false
            && $device->os->setRegex($device->device_ua, '/^Mozilla\/[45]\.[0-9] \((?:Macintosh; )?([a-zA-Z0-9\._ ]+)\) AppleWebKit.+YaBrowser\/([\d\.]+)/', 1)) {
            $device->browser->set('Yandex browser', $device->os->getLastRegexMatch(2));
            return $device;
        }

        //Opera - OPR
        if (strpos($device->device_ua, 'OPR') !== false
            && $device->os->setRegex($device->device_ua, '/^Mozilla\/[0-9]\.0 .+?((?:Windows|Linux|PPC|Intel) [a-zA-Z0-9 _\.\-]+).+Chrome\/.+OPR\/([\d\.]+)/', 1)
        ) {
            $device->browser->set('Opera', $device->os->getLastRegexMatch(2));
            return $device;
        }

        //Opera - Old UA
        if (strpos($device->device_ua, 'Opera') !== false
            && $device->os->setRegex($device->device_ua, '/^Opera\/([\d\.]+) .+?((?:Windows|Linux|PPC|Intel) [a-zA-Z0-9 _\.\-]+) ?;/', 2)) {
            $device->browser->set('Opera', $device->os->getLastRegexMatch(1));
            $device->browser->setRegex($device->browser_ua, '/^Opera\/.+? Version\/([\d\.]+)/', null, 1);
            return $device;
        }
        
        if (strpos($device->device_ua, 'Chrome') !== false) {
            //Chrome Mac
            if ($device->os->setRegex($device->device_ua, '/^Mozilla\/[0-9]\.0 \(Macintosh;(?: U;)?([a-zA-Z_ \.0-9]+)(?:;)?.+? Chrome\/([\d\.]+)\.?/', 1)) {
                $device->browser->set('Chrome', $device->os->getLastRegexMatch(2));
                return $device;
            }
            
            //Chrome
            if ($device->os->setRegex($device->device_ua, '/^Mozilla\/[0-9]\.0 \((?:Windows;|X11;)?(?: U; )?([a-zA-Z_ \.0-9]+)(?:;)?.+? Chrome\/([\d\.]+)\.?/', 1)) {
                $device->browser->set('Chrome', $device->os->getLastRegexMatch(2));
                return $device;
            }
        }
        
        //Safari
        if (strpos($device->device_ua_normalized, 'Safari') !== false
            && $device->os->setRegex($device->device_ua_normalized, '/Mozilla\/[0-9]\.0 \((?:(?:Windows|Macintosh); (?:U; |WOW64; )?)?([a-zA-Z_ \.0-9]+)(?:;)?.+? Version\/([\d\.]+)\.?/', 1)) {
            $device->browser->set('Safari', $device->os->getLastRegexMatch(2));
            return $device;
        }
        
        if (strpos($device->device_ua, 'Firefox') !== false) {
            //Firefox - Windows
            if ($device->os->setRegex($device->device_ua, '/^Mozilla\/[0-9]\.0 .+(Windows [0-9A-Za-z \.]+;).+?rv:.+?Firefox\/([\d\.]+)/', 1)) {
                $device->browser->set('Firefox', $device->os->getLastRegexMatch(2));
                return $device;
            }
            
            //Firefox
            if ($device->os->setRegex($device->device_ua, '/^Mozilla\/[0-9]\.0 \((?:X11|Macintosh); (?:U; |Ubuntu; |)((?:Intel|PPC|Linux) [a-zA-Z0-9\- \._\(\)]+);.+?rv:.+?Firefox\/([\d\.]+)/', 1)) {
                $device->browser->set('Firefox', $device->os->getLastRegexMatch(2));
                return $device;
            }
        }

        // Is UA CFNetwork?
        if (strpos($device->browser_ua, 'CFNetwork') !== false) {
            $device->os->set($this->device->getCapability('device_os'), $this->device->getCapability('device_os_version'));
            $device->browser->set('CFNetwork App', $this->device->getCapability('mobile_browser_version'));
            return $device;
        }
        
        return $device;
    }
384265
public static function build(GenericRequest $request, CustomDevice $customDevice)
    {
        $device = new Device($request);

        self::assignProperties($device, $customDevice);
        self::normalizeOS($device);
        self::normalizeBrowser($device);

        return $device;
    }