WhichBrowser\Model\Device::toString PHP Method

toString() public method

Get the combined name of the manufacturer and model in a human readable format
public toString ( ) : string
return string
    public function toString()
    {
        if ($this->hidden) {
            return '';
        }
        if ($this->identified) {
            $model = $this->getModel();
            $manufacturer = $this->getManufacturer();
            if ($manufacturer != '' && strpos($model, $manufacturer) === 0) {
                $manufacturer = '';
            }
            return trim($manufacturer . ' ' . $model);
        }
        return !empty($this->model) ? 'unrecognized device (' . $this->model . ')' : '';
    }

Usage Example

Example #1
0
 /**
  * Get a human readable string of the whole browser identification
  *
  * @return string
  */
 public function toString()
 {
     $prefix = $this->camouflage ? 'an unknown browser that imitates ' : '';
     $browser = $this->browser->toString();
     $os = $this->os->toString();
     $engine = $this->engine->toString();
     $device = $this->device->toString();
     if (empty($device) && empty($os) && $this->device->type == 'television') {
         $device = 'television';
     }
     if (empty($device) && $this->device->type == 'emulator') {
         $device = 'emulator';
     }
     if (!empty($browser) && !empty($os) && !empty($device)) {
         return $prefix . $browser . ' on ' . $this->a($device) . ' running ' . $os;
     }
     if (!empty($browser) && empty($os) && !empty($device)) {
         return $prefix . $browser . ' on ' . $this->a($device);
     }
     if (!empty($browser) && !empty($os) && empty($device)) {
         return $prefix . $browser . ' on ' . $os;
     }
     if (empty($browser) && !empty($os) && !empty($device)) {
         return $prefix . $this->a($device) . ' running ' . $os;
     }
     if (!empty($browser) && empty($os) && empty($device)) {
         return $prefix . $browser;
     }
     if (empty($browser) && empty($os) && !empty($device)) {
         return $prefix . $this->a($device);
     }
     if ($this->device->type == 'desktop' && !empty($os) && !empty($engine) && empty($device)) {
         return 'an unknown browser based on ' . $engine . ' running on ' . $os;
     }
     if ($this->browser->stock && !empty($os) && empty($device)) {
         return $os;
     }
     if ($this->browser->stock && !empty($engine) && empty($device)) {
         return 'an unknown browser based on ' . $engine;
     }
     if ($this->device->type == 'bot') {
         return 'an unknown bot';
     }
     return 'an unknown browser';
 }
All Usage Examples Of WhichBrowser\Model\Device::toString