*/ class TestPack implements JsonSerializable { /** * The item type * @var string */ private $type; /** * The item data as arrays. Can be anything, just be careful of cyclic refs. * @var array */ private $data = []; /** * The test item's data * @var array */ private $items = []; /** * Creates an TestPack with the required data. * * @param string $type the test type * @param array $data the test data * @param array $items the test items * @throw InvalidArgumentException */ public function __construct($type, $data, $items) { if (empty($type)) { throw new InvalidArgumentException('Please provide a test type'); } if (!is_array($data)) { throw new InvalidArgumentException('Please provide the test data as an array'); } if (!is_array($items)) { throw new InvalidArgumentException('Please provide the items as an array'); } $this->type = $type; $this->data = $data; $this->items = $items; } /** * Get the test type * @return string the type */ public function getType() { return $this->type; } /** * Get the test data * @return array the data */ public function getData() { return $this->data; } /** * Get the test's items * @return array the items */ public function getItems() { return $this->items; } /** * How to serialize the pack in JSON. */ public function JsonSerialize() { return [ 'type' => $this->type, 'data' => $this->data, 'items' => $this->items ]; } }