2015-12-09 19:06:04 +01:00
|
|
|
<?php class Message
|
|
|
|
{
|
2015-12-16 14:38:48 +01:00
|
|
|
public static $TYPE_DISPLAY_NAMES = array("Chat", "PM");
|
2015-12-16 01:22:55 +01:00
|
|
|
|
|
|
|
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;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2016-06-23 21:41:46 +02:00
|
|
|
/** @var User */
|
2015-12-09 19:06:04 +01:00
|
|
|
private $sender;
|
|
|
|
|
2016-06-23 21:41:46 +02:00
|
|
|
/** @var User[] */
|
2015-12-09 19:06:04 +01:00
|
|
|
private $recipients;
|
|
|
|
|
2015-12-15 22:36:54 +01:00
|
|
|
/** @var DateTime */
|
2015-12-09 19:06:04 +01:00
|
|
|
private $timestamp;
|
|
|
|
|
2015-12-16 01:22:55 +01:00
|
|
|
/** @var Int */
|
2015-12-15 22:36:54 +01:00
|
|
|
private $type;
|
|
|
|
|
2015-12-09 19:06:04 +01:00
|
|
|
/** @var String */
|
|
|
|
private $message;
|
|
|
|
|
2016-06-19 23:21:12 +02:00
|
|
|
/** @var String */
|
|
|
|
private $server;
|
|
|
|
|
2015-12-09 19:06:04 +01:00
|
|
|
/**
|
|
|
|
* Message constructor.
|
2016-06-23 21:41:46 +02:00
|
|
|
* @param User $sender
|
|
|
|
* @param User[] $recipients
|
2015-12-15 22:36:54 +01:00
|
|
|
* @param DateTime $dateTime
|
2015-12-16 01:22:55 +01:00
|
|
|
* @param Int $type
|
2016-06-19 23:21:12 +02:00
|
|
|
* @param Message $message
|
|
|
|
* @param String $server
|
2015-12-09 19:06:04 +01:00
|
|
|
*/
|
2016-06-23 15:48:57 +02:00
|
|
|
function __construct($sender, $recipients, $dateTime, $type, $message, $server)
|
2015-12-09 19:06:04 +01:00
|
|
|
{
|
|
|
|
$this->sender = $sender;
|
|
|
|
$this->recipients = $recipients;
|
2015-12-15 22:36:54 +01:00
|
|
|
$this->timestamp = $dateTime;
|
|
|
|
$this->type = $type;
|
2015-12-09 19:06:04 +01:00
|
|
|
$this->message = $message;
|
2016-06-19 23:21:12 +02:00
|
|
|
$this->server = $server;
|
2015-12-09 19:06:04 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
2016-06-23 21:41:46 +02:00
|
|
|
* @return User
|
2015-12-09 19:06:04 +01:00
|
|
|
*/
|
|
|
|
public function getSender()
|
|
|
|
{
|
|
|
|
return $this->sender;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
2016-06-23 21:41:46 +02:00
|
|
|
* @return User[]
|
2015-12-09 19:06:04 +01:00
|
|
|
*/
|
|
|
|
public function getRecipients()
|
|
|
|
{
|
|
|
|
return $this->recipients;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
2015-12-15 22:36:54 +01:00
|
|
|
* @return DateTime
|
2015-12-09 19:06:04 +01:00
|
|
|
*/
|
|
|
|
public function getTimestamp()
|
|
|
|
{
|
|
|
|
return $this->timestamp;
|
|
|
|
}
|
|
|
|
|
2015-12-16 01:22:55 +01:00
|
|
|
/**
|
|
|
|
* @return Int
|
|
|
|
*/
|
2015-12-15 22:36:54 +01:00
|
|
|
public function getType()
|
|
|
|
{
|
|
|
|
return $this->type;
|
|
|
|
}
|
|
|
|
|
2015-12-09 19:06:04 +01:00
|
|
|
/**
|
|
|
|
* @return String
|
|
|
|
*/
|
|
|
|
public function getMessage()
|
|
|
|
{
|
|
|
|
return $this->message;
|
|
|
|
}
|
2016-06-19 23:21:12 +02:00
|
|
|
|
|
|
|
/**
|
|
|
|
* @return String
|
|
|
|
*/
|
|
|
|
public function getServer()
|
|
|
|
{
|
|
|
|
return $this->server;
|
|
|
|
}
|
2015-12-09 19:06:04 +01:00
|
|
|
}
|