generalName = $generalName; $this->nationName = $nationName; $this->color = $color; $this->icon = $icon; } /** * @return MessageTarget */ public static function buildFromArray($arr) { if(!$arr){ return null; } if(!Util::array_get($arr['nation_id'])){ $arr['nation'] = '재야'; $arr['color'] = '#000000'; $arr['nation_id'] = 0; } return new MessageTarget( $arr['id'], $arr['name'], $arr['nation_id'], $arr['nation'], $arr['color'], $arr['icon']??'' ); } public function toArray() : array{ return [ 'id'=>$this->generalID, 'name'=>$this->generalName, 'nation_id'=>$this->nationID, 'nation'=>$this->nationName, 'color'=>$this->color, 'icon'=>$this->icon ]; } public function toArrayLight() : array{ //TODO: 이걸 꼭 연관 배열로 보낼 이유가 없다. //TODO: 아이콘도 축약 가능하다. return [ 'name'=>$this->generalName, 'nation'=>$this->nationName, 'color'=>$this->color, 'icon'=>$this->icon ]; } }