コード例 #1
0
ファイル: FamilyTest.php プロジェクト: vicular/Parser
 public function testToArray()
 {
     $family = new Family();
     $this->assertEquals([], $family->toArray());
     $family->set(['name' => 'Android', 'version' => new Version(['value' => '4.1.1'])]);
     $this->assertEquals(['name' => 'Android', 'version' => '4.1.1'], $family->toArray());
 }
コード例 #2
0
ファイル: Os.php プロジェクト: zunygun/Legacy
 /**
  * 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->family)) {
         $result['family'] = $this->family->toArray();
     }
     if (!empty($this->alias)) {
         $result['alias'] = $this->alias;
     }
     if (!empty($this->version)) {
         $result['version'] = $this->version->toArray();
     }
     if (isset($result['version']) && !count($result['version'])) {
         unset($result['version']);
     }
     return $result;
 }