99 lines
1.7 KiB
PHP
99 lines
1.7 KiB
PHP
|
<?php class Message
|
||
|
{
|
||
|
public static $TYPE_DISPLAY_NAMES = array("Chat", "PM");
|
||
|
|
||
|
const TYPE_CHAT = 0;
|
||
|
const TYPE_PM = 1;
|
||
|
|
||
|
/**
|
||
|
* @param $type
|
||
|
* @return int
|
||
|
*/
|
||
|
public static function getTypeFromString($type)
|
||
|
{
|
||
|
if (strcmp($type, "CHAT") == 0)
|
||
|
{
|
||
|
return self::TYPE_CHAT;
|
||
|
}
|
||
|
else if (strcmp($type, "PM") == 0)
|
||
|
{
|
||
|
return self::TYPE_PM;
|
||
|
}
|
||
|
else
|
||
|
{
|
||
|
return -1;
|
||
|
}
|
||
|
}
|
||
|
|
||
|
/** @var Player */
|
||
|
private $sender;
|
||
|
|
||
|
/** @var Player[] */
|
||
|
private $recipients;
|
||
|
|
||
|
/** @var DateTime */
|
||
|
private $timestamp;
|
||
|
|
||
|
/** @var Int */
|
||
|
private $type;
|
||
|
|
||
|
/** @var String */
|
||
|
private $message;
|
||
|
|
||
|
/**
|
||
|
* Message constructor.
|
||
|
* @param Player $sender
|
||
|
* @param Player[] $recipients
|
||
|
* @param DateTime $dateTime
|
||
|
* @param Int $type
|
||
|
* @param Message
|
||
|
*/
|
||
|
function Message($sender, $recipients, $dateTime, $type, $message)
|
||
|
{
|
||
|
$this->sender = $sender;
|
||
|
$this->recipients = $recipients;
|
||
|
$this->timestamp = $dateTime;
|
||
|
$this->type = $type;
|
||
|
$this->message = $message;
|
||
|
}
|
||
|
|
||
|
/**
|
||
|
* @return Player
|
||
|
*/
|
||
|
public function getSender()
|
||
|
{
|
||
|
return $this->sender;
|
||
|
}
|
||
|
|
||
|
/**
|
||
|
* @return Player[]
|
||
|
*/
|
||
|
public function getRecipients()
|
||
|
{
|
||
|
return $this->recipients;
|
||
|
}
|
||
|
|
||
|
/**
|
||
|
* @return DateTime
|
||
|
*/
|
||
|
public function getTimestamp()
|
||
|
{
|
||
|
return $this->timestamp;
|
||
|
}
|
||
|
|
||
|
/**
|
||
|
* @return Int
|
||
|
*/
|
||
|
public function getType()
|
||
|
{
|
||
|
return $this->type;
|
||
|
}
|
||
|
|
||
|
/**
|
||
|
* @return String
|
||
|
*/
|
||
|
public function getMessage()
|
||
|
{
|
||
|
return $this->message;
|
||
|
}
|
||
|
}
|