2015-12-15 23:13:23 +01:00
|
|
|
<?php class Report
|
2015-12-08 00:43:29 +01:00
|
|
|
{
|
2015-12-15 23:13:23 +01:00
|
|
|
/** @var Int */
|
|
|
|
private $id;
|
2015-12-07 18:05:58 +01:00
|
|
|
|
2016-06-23 21:41:46 +02:00
|
|
|
/** @var User|Null */
|
2015-12-16 17:01:19 +01:00
|
|
|
private $handler;
|
|
|
|
|
2016-06-23 21:41:46 +02:00
|
|
|
/** @var User */
|
2015-12-15 23:13:23 +01:00
|
|
|
private $suspect;
|
2015-12-09 19:06:04 +01:00
|
|
|
|
2016-07-07 23:51:05 +02:00
|
|
|
/** @var UserReport[] */
|
2015-12-15 23:13:23 +01:00
|
|
|
private $reporters;
|
2015-12-08 00:43:29 +01:00
|
|
|
|
2016-06-19 23:21:12 +02:00
|
|
|
/** @var Int */
|
|
|
|
private $category;
|
|
|
|
|
2015-12-15 23:13:23 +01:00
|
|
|
/**
|
|
|
|
* Report constructor.
|
|
|
|
* @param Int $id
|
2016-06-23 21:41:46 +02:00
|
|
|
* @param User|Null $handler
|
|
|
|
* @param User $suspect
|
2016-07-07 23:51:05 +02:00
|
|
|
* @param UserReport[] $reporters
|
2016-06-19 23:21:12 +02:00
|
|
|
* @param Int $category
|
2015-12-15 23:13:23 +01:00
|
|
|
*/
|
2016-10-11 01:45:33 +02:00
|
|
|
function __construct($id, $handler, $suspect, $reporters, $category)
|
2015-12-08 00:43:29 +01:00
|
|
|
{
|
2015-12-15 23:13:23 +01:00
|
|
|
$this->id = $id;
|
2015-12-16 17:01:19 +01:00
|
|
|
$this->handler = $handler;
|
2015-12-15 23:13:23 +01:00
|
|
|
$this->suspect = $suspect;
|
|
|
|
$this->reporters = $reporters;
|
2016-06-19 23:21:12 +02:00
|
|
|
$this->category = $category;
|
2015-12-08 00:43:29 +01:00
|
|
|
}
|
|
|
|
|
2016-06-30 23:23:29 +02:00
|
|
|
/**
|
|
|
|
* @return DateTime
|
|
|
|
*/
|
|
|
|
public function getTimeCreated()
|
|
|
|
{
|
|
|
|
return $this->getOldestReport()->getTime();
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
2016-07-07 23:51:05 +02:00
|
|
|
* @return UserReport
|
2016-06-30 23:23:29 +02:00
|
|
|
*/
|
|
|
|
private function getOldestReport()
|
|
|
|
{
|
2016-07-07 23:51:05 +02:00
|
|
|
/** @var UserReport $oldestReason */
|
2016-06-30 23:23:29 +02:00
|
|
|
$oldestReason = null;
|
|
|
|
|
|
|
|
foreach ($this->reporters as $reason)
|
|
|
|
{
|
2016-06-30 23:51:16 +02:00
|
|
|
if ($oldestReason == null || $oldestReason->getTime()->diff($reason->getTime())->invert)
|
2016-06-30 23:23:29 +02:00
|
|
|
{
|
|
|
|
$oldestReason = $reason;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return $oldestReason;
|
|
|
|
}
|
|
|
|
|
2015-12-15 23:13:23 +01:00
|
|
|
/**
|
|
|
|
* @return Int
|
|
|
|
*/
|
|
|
|
public function getId()
|
2015-12-08 00:43:29 +01:00
|
|
|
{
|
2015-12-15 23:13:23 +01:00
|
|
|
return $this->id;
|
2015-12-08 00:43:29 +01:00
|
|
|
}
|
|
|
|
|
2015-12-16 17:01:19 +01:00
|
|
|
/**
|
2016-06-23 21:41:46 +02:00
|
|
|
* @return User|Null
|
2015-12-16 17:01:19 +01:00
|
|
|
*/
|
|
|
|
public function getHandler()
|
|
|
|
{
|
|
|
|
return $this->handler;
|
|
|
|
}
|
|
|
|
|
2015-12-15 23:13:23 +01:00
|
|
|
/**
|
2016-06-23 21:41:46 +02:00
|
|
|
* @return User
|
2015-12-15 23:13:23 +01:00
|
|
|
*/
|
|
|
|
public function getSuspect()
|
2015-12-08 00:43:29 +01:00
|
|
|
{
|
2015-12-15 23:13:23 +01:00
|
|
|
return $this->suspect;
|
2015-12-08 00:43:29 +01:00
|
|
|
}
|
2015-12-15 23:13:23 +01:00
|
|
|
|
|
|
|
/**
|
2016-07-07 23:51:05 +02:00
|
|
|
* @return UserReport[]
|
2015-12-15 23:13:23 +01:00
|
|
|
*/
|
|
|
|
public function getReporters()
|
2015-12-08 00:43:29 +01:00
|
|
|
{
|
2015-12-15 23:13:23 +01:00
|
|
|
return $this->reporters;
|
2015-12-08 00:43:29 +01:00
|
|
|
}
|
2016-06-19 23:21:12 +02:00
|
|
|
|
|
|
|
/**
|
|
|
|
* @return Int
|
|
|
|
*/
|
|
|
|
public function getCategory()
|
|
|
|
{
|
|
|
|
return $this->category;
|
|
|
|
}
|
2015-12-15 23:13:23 +01:00
|
|
|
}
|