getBrandName() public method

Returns the full device brand name extracted from the parsed UA
See also: self::$deviceBrand for available device brands
public getBrandName ( ) : string
return string
Example #1
0
 public function detect($userAgent = null, $advanced = false)
 {
     $userAgent = $userAgent ?: env('HTTP_USER_AGENT');
     DeviceParserAbstract::setVersionTruncation(DeviceParserAbstract::VERSION_TRUNCATION_NONE);
     $detect = new DeviceDetector($userAgent);
     $detect->parse();
     $return = [];
     if ($detect->isBot()) {
         $return['bot'] = $detect->getBot();
         return $return;
     }
     //device wrapper
     $devicelist = ['desktop' => 'computer', 'smartphone' => 'phone', 'tablet' => 'tablet', 'feature phone' => 'phone'];
     $os = $detect->getOs();
     $client = $detect->getClient();
     $devicename = $detect->getDeviceName();
     $devicetype = isset($devicelist[$devicename]) ? $devicelist[$devicename] : 'computer';
     //legacy params
     $return['device'] = $devicename;
     $return['type'] = $devicetype;
     $return['brand'] = $detect->getBrandName();
     $return['os'] = $os['name'];
     $return['os_version'] = $os['version'];
     $return['os_code'] = $os['short_name'];
     $return['browser'] = $client['name'];
     $return['browser_version'] = $client['version'];
     $return['browser_code'] = $client['short_name'];
     $return['browser_type'] = $client['type'];
     $return['browser_engine'] = $client['engine'];
     if (!$advanced) {
         return array_map('trim', $return);
     }
     //advanced params
     $osFamily = OperatingSystem::getOsFamily($os['short_name']);
     $return['os_family'] = $osFamily !== false ? $osFamily : 'Unknown';
     $return['model'] = $detect->getModel();
     $browserFamily = Browser::getBrowserFamily($client['short_name']);
     $return['browser_family'] = $browserFamily !== false ? $browserFamily : 'Unknown';
     $touch = $detect->isTouchEnabled();
     $return['touch'] = $touch[0];
     unset($os, $client, $osFamily, $browserFamily, $touch);
     return array_map('trim', $return);
 }
Example #2
0
 public function testGetBrandName()
 {
     $dd = new DeviceDetector('Mozilla/5.0 (Linux; Android 4.4.2; Nexus 4 Build/KOT49H) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/33.0.1750.136 Mobile Safari/537.36');
     $dd->parse();
     $this->assertEquals('Google', $dd->getBrandName());
 }
 public function getOSManufacturer()
 {
     return $this->deviceDetector->getBrandName();
 }
 /**
  * Returns client device details from client browser
  *
  * @param class $deviceDetectorClass
  * @return array
  */
 private function getClientBrowserDevice(\DeviceDetector\DeviceDetector $deviceDetectorClass)
 {
     $this->autoPopulateSuperGlobals();
     $clientIp = $this->brServerGlobals->getClientIp();
     return ['brand' => $deviceDetectorClass->getDeviceName(), 'ip' => $clientIp, 'ip direct' => $this->brServerGlobals->server->get('REMOTE_ADDR'), 'ip type' => $this->checkIpIsPrivate($clientIp), 'ip v4/v6' => $this->checkIpIsV4OrV6($clientIp), 'model' => $deviceDetectorClass->getModel(), 'name' => $deviceDetectorClass->getBrandName()];
 }
Example #5
0
 public function registerDevice($userId = null)
 {
     $guid = $this->createTag();
     $userAgent = Yii::$app->request->userAgent;
     $dd = new DeviceDetector($userAgent);
     $dd->parse();
     $os = $dd->getOs();
     $client = $dd->getClient();
     $device = new DeviceModel();
     $device->guid = $guid;
     $device->device = $dd->getDeviceName();
     $device->model = $dd->getModel();
     $device->brand = $dd->getBrandName();
     $device->os_name = $os['name'];
     $device->os_version = $os['version'];
     $device->client_type = $client['type'];
     $device->client_name = $client['name'];
     $device->client_version = $client['version'];
     $device->user_id = $userId;
     Yii::$app->session->set('deviceId', $device->id);
     if (!$device->save()) {
         Yii::error(['info' => 'Проблема создания устройства в БД', 'message' => $device->getErrors()], __LINE__);
         return $device->getErrors();
     }
     $this->setTag($guid);
     $this->id = $device->id;
     $this->tag = $guid;
     return $device;
 }
 /**
  *
  * @param Model\UserAgent $device
  * @param DeviceDetector  $dd
  */
 private function hydrateDevice(Model\Device $device, DeviceDetector $dd)
 {
     $device->setModel($this->getRealResult($dd->getModel()));
     $device->setBrand($this->getRealResult($dd->getBrandName()));
     $device->setType($this->getRealResult($dd->getDeviceName()));
     if ($dd->isMobile() === true) {
         $device->setIsMobile(true);
     }
     if ($dd->isTouchEnabled() === true) {
         $device->setIsTouch(true);
     }
 }