Mineplex2018-withcommit/Plugins/Mineplex.ReportSite/report.php
2016-07-07 17:49:06 -04:00

101 lines
1.8 KiB
PHP

<?php class Report
{
/** @var Int */
private $id;
/** @var User|Null */
private $handler;
/** @var User */
private $suspect;
/** @var ReporterReason[] */
private $reporters;
/** @var Int */
private $category;
/**
* Report constructor.
* @param Int $id
* @param User|Null $handler
* @param User $suspect
* @param ReporterReason[] $reporters
* @param Int $category
*/
function __construct($id, $handler, $suspect, $reporters, $category)
{
$this->id = $id;
$this->handler = $handler;
$this->suspect = $suspect;
$this->reporters = $reporters;
$this->category = $category;
}
/**
* @return DateTime
*/
public function getTimeCreated()
{
return $this->getOldestReport()->getTime();
}
/**
* @return ReporterReason
*/
private function getOldestReport()
{
/** @var ReporterReason $oldestReason */
$oldestReason = null;
foreach ($this->reporters as $reason)
{
if ($oldestReason == null || $oldestReason->getTime()->diff($reason->getTime())->invert)
{
$oldestReason = $reason;
}
}
return $oldestReason;
}
/**
* @return Int
*/
public function getId()
{
return $this->id;
}
/**
* @return User|Null
*/
public function getHandler()
{
return $this->handler;
}
/**
* @return User
*/
public function getSuspect()
{
return $this->suspect;
}
/**
* @return ReporterReason[]
*/
public function getReporters()
{
return $this->reporters;
}
/**
* @return Int
*/
public function getCategory()
{
return $this->category;
}
}