Files
scummvm-web/include/Objects/GameDemo.php
T
Mataniko 4d78399ea2 WEB: Add error handling about missing required fields
In the new data model, some field operate as keys for other parts of the model.
This now performs some validations and will throw an error if fields are missing.

For example: a Game must have an Engine, but does not require datafiles
2020-09-27 22:08:07 -04:00

63 lines
1.5 KiB
PHP

<?php
namespace ScummVM\Objects;
/**
* The GameDemo class represents a game demo item on the website.
*/
class GameDemo extends DataObject
{
private $url;
private $category;
private $platform;
private $game;
/* GameDemo object constructor. */
public function __construct($data, $games, $platforms)
{
parent::__construct($data);
$this->url = $this->assignFromArray('url', $data, true);
$this->platform = $this->assignFromArray($data['platform'], $platforms, true);
$this->game = $this->assignFromArray($data['id'], $games, true);
$this->category = $this->assignFromArray('category', $data);
}
public function __toString()
{
return $this->getName();
}
/* Get the download URL for the demo. */
public function getURL()
{
return $this->url;
}
/* Get the platform for the demo. */
public function getPlatform()
{
return $this->platform;
}
/* Get the game for the demo. */
public function getGame()
{
return $this->game;
}
/* Get the category for the demo. */
public function getCategory()
{
return $this->category;
}
/* Get the category for the demo. */
public function getName()
{
$gameName = $this->game->getName();
$platformName = $this->platform->getName();
$category = $this->getCategory();
return "$gameName ($platformName $category Demo)";
}
}
//