메시지 클래스 새로 작성
This commit is contained in:
@@ -0,0 +1,50 @@
|
||||
<?php
|
||||
namespace sammo;
|
||||
|
||||
class MessageTarget {
|
||||
/** @var int */
|
||||
public $generalID;
|
||||
/** @var int */
|
||||
public $nationID;
|
||||
|
||||
/** @var string */
|
||||
public $nationName;
|
||||
/** @var string */
|
||||
public $color;
|
||||
|
||||
public function __construct(int $generalID, int $nationID, string $nationName, string $color){
|
||||
|
||||
|
||||
if($mailbox > Message::MAILBOX_NATIONAL){
|
||||
$this->isGeneral = false;
|
||||
}
|
||||
else{
|
||||
$this->isGeneral = true;
|
||||
}
|
||||
|
||||
$this->generalID = $generalID;
|
||||
$this->nationID = $nationID;
|
||||
$this->nationName = $nationName;
|
||||
$this->color = $color;
|
||||
}
|
||||
|
||||
public static function buildFromArray(array $arr) : MessageTarget
|
||||
{
|
||||
if(!Util::array_get($arr['nation'])){
|
||||
$arr['nation'] = '재야';
|
||||
$arr['color'] = '#ffffff';
|
||||
$arr['nation_id'] = 0;
|
||||
}
|
||||
|
||||
return new MessageTarget($arr['id'], $arr['nation_id'], $arr['nation'], $arr['color']);
|
||||
}
|
||||
|
||||
public function toArray() : array{
|
||||
return [
|
||||
'id'=>$this->generalID,
|
||||
'nation_id'=>$this->nationID,
|
||||
'nation'=>$this->nationName,
|
||||
'color'=>$this->color
|
||||
];
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user