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()); }
/** * 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; }