mirror of
https://github.com/scummvm/scummvm-web.git
synced 2026-05-21 05:40:47 +00:00
4d78399ea2
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
63 lines
1.5 KiB
PHP
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)";
|
|
}
|
|
}
|
|
//
|