internalAdd(self::ITEM_TYPE, $itemDto); } public function addHero($heroDto) { $this->internalAdd(self::HERO_TYPE, $heroDto); } public function addHeroSkin($heroSkinDto) { $this->internalAdd(self::HEROSKIN_TYPE, $heroSkinDto); } public function addGunSkin($gunSkinDto) { $this->internalAdd(self::GUNSKIN_TYPE, $gunSkinDto); } public function toDto() { return array( 'items' => $this->items ); } private function internalAdd($type, $dto) { array_push($items, array( 'type' => $type, "union_${type}" => $dto )); } }