MessageTarget의 부모 클래스 Target 추가
This commit is contained in:
@@ -1,12 +1,7 @@
|
||||
<?php
|
||||
namespace sammo;
|
||||
|
||||
class MessageTarget {
|
||||
/** @var int */
|
||||
public $generalID;
|
||||
/** @var int */
|
||||
public $nationID;
|
||||
|
||||
class MessageTarget extends Target {
|
||||
/** @var string */
|
||||
public $generalName;
|
||||
/** @var string */
|
||||
@@ -16,6 +11,7 @@ class MessageTarget {
|
||||
|
||||
public function __construct(int $generalID, string $generalName, int $nationID, string $nationName, string $color){
|
||||
|
||||
parent::__construct($generalID, $nationID);
|
||||
|
||||
if($mailbox > Message::MAILBOX_NATIONAL){
|
||||
$this->isGeneral = false;
|
||||
@@ -24,9 +20,7 @@ class MessageTarget {
|
||||
$this->isGeneral = true;
|
||||
}
|
||||
|
||||
$this->generalID = $generalID;
|
||||
$this->generalName = $generalName;
|
||||
$this->nationID = $nationID;
|
||||
$this->nationName = $nationName;
|
||||
$this->color = $color;
|
||||
}
|
||||
|
||||
@@ -0,0 +1,27 @@
|
||||
<?php
|
||||
namespace sammo;
|
||||
|
||||
class Target {
|
||||
/** @var int */
|
||||
public $generalID;
|
||||
/** @var int */
|
||||
public $nationID;
|
||||
|
||||
public function __construct(int $generalID, int $nationID){
|
||||
|
||||
$this->generalID = $generalID;
|
||||
$this->nationID = $nationID;
|
||||
}
|
||||
|
||||
public static function buildFromArray(array $arr) : Target
|
||||
{
|
||||
return new Target($arr['id'], $arr['nation_id']??0);
|
||||
}
|
||||
|
||||
public function toArray() : array{
|
||||
return [
|
||||
'id'=>$this->generalID,
|
||||
'nation_id'=>$this->nationID
|
||||
];
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user