Пример #1
0
 public function testToArray()
 {
     $engine = new Engine();
     $this->assertEquals([], $engine->toArray());
     $engine->set(['name' => null]);
     $this->assertEquals([], $engine->toArray());
     $engine->reset(['name' => 'WebKit', 'version' => new Version(['value' => '601.3.9'])]);
     $this->assertEquals(['name' => 'WebKit', 'version' => '601.3.9'], $engine->toArray());
 }
Пример #2
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;
 }