/Aurora/Addon/WebAPI/AbuseReports.php
https://bitbucket.org/VirtualReality/libaurora.php · PHP · 342 lines · 219 code · 30 blank · 93 comment · 26 complexity · 8d01f60775d1a36fd838ff2a0338b423 MD5 · raw file
- <?php
- //! @file Aurora/Addon/WebAPI/AbuseReports.php
- //! @brief Abuse Report-related WebAPI code
- //! @author SignpostMarv
- namespace Aurora\Addon\WebAPI{
- use libAurora\abstractIterator;
- //! AbuseReport class. Included in result returned by Aurora::Addon::WebAPI::GetAbuseReports()
- class AbuseReport{
- //! protected constructor, we hide it behind a registry method.
- /**
- * @param integer $number looks like the primary key according to IAbuseReports.GetAbuseReport
- * @param string $details abuse report details
- * @param string $location abuse report location
- * @param string $userName name of the account being reported
- * @param string $summary summary of abuse report
- * @param boolean $active whether or not the abuse report is open.
- * @param string $assignedTo name of admin the abuse report is assigned to.
- * @param string $category category of abuse
- * @param boolean $checked not entirely sure what this does.
- * @param string $notes notes on the abuse report.
- * @param string $objectName Name of object being reported (if applicable)
- * @param string $objectPosition Position of object being reported (if applicable)
- * @param string $objectUUID UUID of object being reported (if applicable)
- * @param string $regionName region the report originated from
- * @param string $reporterName account name of the user who filed the abuse report
- * @param string $screenshot asset UUID of screenshot attached to the abuse report
- */
- protected function __construct($number, $details, $location, $userName, $summary, $active, $assignedTo, $category, $checked, $notes, $objectName, $objectPosition, $objectUUID, $regionName, $reporterName, $screenshot){
- if(is_integer($number) === false){
- throw new InvalidArgumentException('AR Number must be an integer.');
- }else if(is_string($details) === false){
- throw new InvalidArgumentException('AR Details must be a string.');
- }else if(is_string($location) === false){
- throw new InvalidArgumentException('AR Location must be a string.');
- }else if(is_string($userName) === false){
- throw new InvalidArgumentException('AR accused name must be a string.');
- }else if(is_string($summary) === false){
- throw new InvalidArgumentException('AR summary must be a string.');
- }else if(is_bool($active) === false){
- throw new InvalidArgumentException('AR activity flag must be a boolean.');
- }else if(is_string($assignedTo) === false){
- throw new InvalidArgumentException('AR admin assignee name must be a string.');
- }else if(is_string($category) === false){
- throw new InvalidArgumentException('AR category must be a string.');
- }else if(is_bool($checked) === false){
- throw new InvalidArgumentException('AR checked flag must be a boolean.');
- }else if(is_string($notes) === false){
- throw new InvalidArgumentException('AR notes must be a string.');
- }else if(is_string($objectName) === false){
- throw new InvalidArgumentException('AR object name must be a string.');
- }else if(is_string($objectPosition) === false){
- throw new InvalidArgumentException('AR object position must be a string.');
- }else if(is_string($objectUUID) === false){
- throw new InvalidArgumentException('AR object UUID must be a string.');
- }else if(preg_match(\Aurora\Addon\WebAPI::regex_UUID, $objectUUID) !== 1){
- throw new InvalidArgumentException('AR object UUID must be a valid UUID.');
- }else if(is_string($regionName) === false){
- throw new InvalidArgumentException('AR region of origin must be a string.');
- }else if(is_string($reporterName) === false){
- throw new InvalidArgumentException('AR reporter name must be as string.');
- }else if(is_string($screenshot) === false){
- throw new InvalidArgumentException('AR screenshot UUID must be a string.');
- }else if(preg_match(\Aurora\Addon\WebAPI::regex_UUID, $screenshot) === false){
- throw new InvalidArgumentException('AR screenshot UUID must be a valid UUID.');
- }
- $this->Number = $number;
- $this->Details = trim($details);
- $this->Location = trim($location);
- $this->UserName = trim($userName);
- $this->Summary = trim($summary);
- $this->Active = $active;
- $this->AssignedTo = trim($assignedTo);
- $this->Category = trim($category);
- $this->Checked = $checked;
- $this->Notes = trim($notes);
- $this->ObjectName = trim($objectName);
- $this->ObjectPosition = trim($objectPosition);
- $this->ObjectUUID = $objectUUID;
- $this->RegionName = trim($regionName);
- $this->ReporterName = trim($reporterName);
- $this->Screenshot = $screenshot;
- }
- //! registry method
- /**
- * @param integer $number looks like the primary key according to IAbuseReports.GetAbuseReport
- * @param string $details abuse report details
- * @param string $location abuse report location
- * @param string $userName name of the account being reported
- * @param string $summary summary of abuse report
- * @param boolean $active whether or not the abuse report is open.
- * @param string $assignedTo name of admin the abuse report is assigned to.
- * @param string $category category of abuse
- * @param boolean $checked not entirely sure what this does.
- * @param string $notes notes on the abuse report.
- * @param string $objectName Name of object being reported (if applicable)
- * @param string $objectPosition Position of object being reported (if applicable)
- * @param string $objectUUID UUID of object being reported (if applicable)
- * @param string $regionName region the report originated from
- * @param string $reporterName account name of the user who filed the abuse report
- * @param string $screenshot asset UUID of screenshot attached to the abuse report
- * @return object an instance of Aurora::Addon::WebAPI::AbuseReport
- */
- public static function r($number, $details=null, $location=null, $userName=null, $summary=null, $active=null, $assignedTo=null, $category=null, $checked=null, $notes=null, $objectName=null, $objectPosition=null, $objectUUID=null, $regionName=null, $reporterName=null, $screenshot=null){
- if(
- is_object($number) &&
- property_exists($number,'Number') &&
- property_exists($number,'AbuseDetails') &&
- property_exists($number,'AbuseLocation') &&
- property_exists($number,'AbuserName') &&
- property_exists($number,'AbuseSummary') &&
- property_exists($number,'Active') &&
- property_exists($number,'AssignedTo') &&
- property_exists($number,'Category') &&
- property_exists($number,'Checked') &&
- property_exists($number,'Notes') &&
- property_exists($number,'ObjectName') &&
- property_exists($number,'ObjectPosition') &&
- property_exists($number,'ObjectUUID') &&
- property_exists($number,'RegionName') &&
- property_exists($number,'ReporterName') &&
- property_exists($number,'ScreenshotID')
- ){
- $details = $number->AbuseDetails;
- $location = $number->AbuseLocation;
- $userName = $number->AbuserName;
- $summary = $number->AbuseSummary;
- $active = $number->Active;
- $assignedTo = $number->AssignedTo;
- $category = $number->Category;
- $checked = $number->Checked;
- $notes = $number->Notes;
- $objectName = $number->ObjectName;
- $objectPosition = $number->ObjectPosition;
- $objectUUID = $number->ObjectUUID;
- $regionName = $number->RegionName;
- $reporterName = $number->ReporterName;
- $screenshot = $number->ScreenshotID;
- $number = $number->Number;
- }
- if(is_integer($number) === false){
- throw new InvalidArgumentException('AR number must be an integer.');
- }
- static $registry = array();
- $create = (isset($registry[$number]) === false);
- if($create === true && isset($details, $location, $userName, $summary, $active, $assignedTo, $category, $checked, $notes, $objectName, $objectPosition, $objectUUID, $regionName, $reporterName, $screenshot) === false){
- throw new InvalidArgumentException('Cannot return cached AbuseReport object as it hasn\'t been created.');
- }else if($create === false){
- $details = trim($details);
- $location = trim($location);
- $userName = trim($userName);
- $summary = trim($summary);
- $assignedTo = trim($assignedTo);
- $category = trim($category);
- $notes = trim($notes);
- $objectName = trim($objectName);
- $objectPosition = trim($objectPosition);
- $regionName = trim($regionName);
- $reporterName = trim($reporterName);
- $AR = $registry[$number];
- $create = (
- $AR->Details() !== $details ||
- $AR->Location() !== $location ||
- $AR->UserName() !== $userName ||
- $AR->Summary() !== $summary ||
- $AR->Active() !== $active ||
- $AR->AssignedTo() !== $assignedTo ||
- $AR->Category() !== $category ||
- $AR->Checked() !== $checked ||
- $AR->Notes() !== $notes ||
- $AR->ObjectName() !== $objectName ||
- $AR->ObjectPosition() !== $objectPosition ||
- $AR->ObjectUUID() !== $objectUUID ||
- $AR->RegionName() !== $regionName ||
- $AR->ReporterName() !== $reporterName ||
- $AR->Screenshot() !== $screenshot
- );
- }
- if($create === true){
- $registry[$number] = new static($number, $details, $location, $userName, $summary, $active, $assignedTo, $category, $checked, $notes, $objectName, $objectPosition, $objectUUID, $regionName, $reporterName, $screenshot);
- }
- return $registry[$number];
- }
- //! integer looks like the primary key according to IAbuseReports.GetAbuseReport
- //! @see Aurora::Addon::WebAPI::AbuseReport::Number()
- protected $Number;
- //! @see Aurora::Addon::WebAPI::AbuseReport::$Number
- public function Number(){
- return $this->Number;
- }
- //! string abuse report details
- //! @see Aurora::Addon::WebAPI::AbuseReport::Details()
- protected $Details;
- //! @see Aurora::Addon::WebAPI::AbuseReport::$Details
- public function Details(){
- return $this->Details;
- }
- //! string abuse report location
- //! @see Aurora::Addon::WebAPI::AbuseReport::Location()
- protected $Location;
- //! @see Aurora::Addon::WebAPI::AbuseReport::$Location
- public function Location(){
- return $this->Location;
- }
- //! string name of the account being reported
- //! @see Aurora::Addon::WebAPI::AbuseReport::UserName()
- protected $UserName;
- //! @see Aurora::Addon::WebAPI::AbuseReport::$UserName
- public function UserName(){
- return $this->UserName;
- }
- //! string summary of abuse report
- //! @see Aurora::Addon::WebAPI::AbuseReport::Summary()
- protected $Summary;
- //! @see Aurora::Addon::WebAPI::AbuseReport::$Summary
- public function Summary(){
- return $this->Summary;
- }
- //! boolean whether or not the abuse report is open.
- //! @see Aurora::Addon::WebAPI::AbuseReport::Active()
- protected $Active;
- //! @see Aurora::Addon::WebAPI::AbuseReport::$Active
- public function Active(){
- return $this->Active;
- }
- //! string name of admin the abuse report is assigned to.
- //! @see Aurora::Addon::WebAPI::AbuseReport::AssignedTo()
- protected $AssignedTo;
- //! @see Aurora::Addon::WebAPI::AbuseReport::$AssignedTo
- public function AssignedTo(){
- return $this->AssignedTo;
- }
- //! string category of abuse
- //! @see Aurora::Addon::WebAPI::AbuseReport::Category()
- protected $Category;
- //! @see Aurora::Addon::WebAPI::AbuseReport::$Category
- public function Category(){
- return $this->Category;
- }
- //! boolean not entirely sure what this does.
- //! @see Aurora::Addon::WebAPI::AbuseReport::Checked()
- protected $Checked;
- //! @see Aurora::Addon::WebAPI::AbuseReport::$Checked
- public function Checked(){
- return $this->Checked;
- }
- //! string notes on the abuse report.
- //! @see Aurora::Addon::WebAPI::AbuseReport::Notes()
- protected $Notes;
- //! @see Aurora::Addon::WebAPI::AbuseReport::$Notes
- public function Notes(){
- return $this->Notes;
- }
- //! string Name of object being reported (if applicable)
- //! @see Aurora::Addon::WebAPI::AbuseReport::ObjectName()
- protected $ObjectName;
- //! @see Aurora::Addon::WebAPI::AbuseReport::$ObjectName
- public function ObjectName(){
- return $this->ObjectName;
- }
- //! string Position of object being reported (if applicable)
- //! @see Aurora::Addon::WebAPI::AbuseReport::ObjectPosition()
- protected $ObjectPosition;
- //! @see Aurora::Addon::WebAPI::AbuseReport::$ObjectPosition
- public function ObjectPosition(){
- return $this->ObjectPosition;
- }
- //! string UUID of object being reported (if applicable)
- //! @see Aurora::Addon::WebAPI::AbuseReport::ObjectUUID()
- protected $ObjectUUID;
- //! @see Aurora::Addon::WebAPI::AbuseReport::$ObjectUUID
- public function ObjectUUID(){
- return $this->ObjectUUID;
- }
- //! string region the report originated from
- //! @see Aurora::Addon::WebAPI::AbuseReport::RegionName()
- protected $RegionName;
- //! @see Aurora::Addon::WebAPI::AbuseReport::$RegionName
- public function RegionName(){
- return $this->RegionName;
- }
- //! string account name of the user who filed the abuse report
- //! @see Aurora::Addon::WebAPI::AbuseReport::ReporterName()
- protected $ReporterName;
- //! @see Aurora::Addon::WebAPI::AbuseReport::$ReporterName
- public function ReporterName(){
- return $this->ReporterName;
- }
- //! string asset UUID of screenshot attached to the abuse report
- //! @see Aurora::Addon::WebAPI::AbuseReport::Screenshot()
- protected $Screenshot;
- //! @see Aurora::Addon::WebAPI::AbuseReport::$Screenshot
- public function Screenshot(){
- return $this->Screenshot;
- }
- }
- //! AbuseReports iterator. Returned by Aurora::Addon::WebAPI::GetAbuseReports()
- class AbuseReports extends abstractIterator{
- //! public constructor
- public function __construct(array $ARs=null){
- if(isset($ARs) === true){
- foreach($ARs as $AR){
- if(($AR instanceof AbuseReport) === false){
- throw new InvalidArgumentException('Only instances of Aurora::Addon::WebAPI::AbuseReport should be included in the array passed to Aurora::Addon::WebAPI::AbuseReports::__construct()');
- }
- }
- reset($ARs);
- $this->data = $ARs;
- }
- }
- }
- }
- ?>