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
48 lines
980 B
PHP
48 lines
980 B
PHP
<?php
|
|
namespace ScummVM\Objects;
|
|
|
|
/**
|
|
* The BasicObject class is inherited by all other objects and houses all common
|
|
* functions.
|
|
*/
|
|
abstract class BasicObject
|
|
{
|
|
protected $name;
|
|
protected $description;
|
|
|
|
public function __construct($data)
|
|
{
|
|
$this->description = $data['description'];
|
|
$this->name = $data['name'];
|
|
}
|
|
|
|
public function __toString()
|
|
{
|
|
return $this->getName();
|
|
}
|
|
|
|
/* Get the name. */
|
|
public function getName()
|
|
{
|
|
return $this->name;
|
|
}
|
|
|
|
public function getDescription()
|
|
{
|
|
return $this->description;
|
|
}
|
|
|
|
/**
|
|
* If the input array doesn't contain the numerical key 0, wrap it inside
|
|
* an array. This functions operates on the data directly.
|
|
*
|
|
* @param mixed $data the input
|
|
*/
|
|
public static function toArray(&$data)
|
|
{
|
|
if (!is_array($data) || !array_key_exists(0, $data)) {
|
|
$data = array($data);
|
|
}
|
|
}
|
|
}
|