WhichBrowser\Model\Device::toArray PHP Method

toArray() public method

Get an array of all defined properties
public toArray ( ) : array
return array
    public function toArray()
    {
        $result = [];
        if (!empty($this->type)) {
            $result['type'] = $this->type;
        }
        if (!empty($this->subtype)) {
            $result['subtype'] = $this->subtype;
        }
        if (!empty($this->manufacturer)) {
            $result['manufacturer'] = $this->manufacturer;
        }
        if (!empty($this->model)) {
            $result['model'] = $this->model;
        }
        if (!empty($this->series)) {
            $result['series'] = $this->series;
        }
        if (!empty($this->carrier)) {
            $result['carrier'] = $this->carrier;
        }
        return $result;
    }

Usage Example

Example #1
0
 /**
  * Get an array of all defined properties
  *
  * @return array
  */
 public function toArray()
 {
     $result = ['browser' => $this->browser->toArray(), 'engine' => $this->engine->toArray(), 'os' => $this->os->toArray(), 'device' => $this->device->toArray()];
     if (!count($result['browser'])) {
         unset($result['browser']);
     }
     if (!count($result['engine'])) {
         unset($result['engine']);
     }
     if (!count($result['os'])) {
         unset($result['os']);
     }
     if (!count($result['device'])) {
         unset($result['device']);
     }
     if ($this->camouflage) {
         $result['camouflage'] = true;
     }
     return $result;
 }
All Usage Examples Of WhichBrowser\Model\Device::toArray