MessageTarget의 부모 클래스 Target 추가

This commit is contained in:
2018-04-14 22:12:40 +09:00
parent 4ebe51d978
commit e614092690
2 changed files with 29 additions and 8 deletions
+2 -8
View File
@@ -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;
}
+27
View File
@@ -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
];
}
}