示例#1
0
 public function testToArray()
 {
     $using = new Using();
     $this->assertEquals([], $using->toArray());
     $using->set(['name' => 'Crosswalk WebView', 'version' => new Version(['value' => '11'])]);
     $this->assertEquals(['name' => 'Crosswalk WebView', 'version' => '11'], $using->toArray());
 }
示例#2
0
 /**
  * Get an array of all defined properties
  *
  * @internal
  *
  * @return array
  */
 public function toArray()
 {
     $result = [];
     if (!empty($this->name)) {
         $result['name'] = $this->name;
     }
     if (!empty($this->alias)) {
         $result['alias'] = $this->alias;
     }
     if (!empty($this->using)) {
         $result['using'] = $this->using->toArray();
     }
     if (!empty($this->family)) {
         $result['family'] = $this->family->toArray();
     }
     if (!empty($this->version)) {
         $result['version'] = $this->version->toArray();
     }
     if (!empty($this->type)) {
         $result['type'] = $this->type;
     }
     if (isset($result['version']) && !count($result['version'])) {
         unset($result['version']);
     }
     return $result;
 }