*/ public function toObject() { $return = parent::toObject(); $return['type'] = 'OrderedCollection'; if ($this->totalItems > 0) { foreach($this->items as $item) { $return['OrderedItems'][] = $item->toObject(); } } return $return; } /** * create object from json * @param array $json input json * @return bool true on success */ public function fromJson($json) : bool { return parent::fromJson($json); } public function append(APObject &$item) : void { $this->items[] = $item; $this->totalItems = sizeof($this->items); } /** * get item with given index * @return APObject|false */ public function get(int $index) { if ($index >= 0) { if ($index >= $this->totalItems) { return false; } return $this->items[$index]; } else { if ($this->totalItems+ $index < 0) { return false; } return $this->items[$this->totalItems + $index]; } } /** * set items * @param APObject[] $items */ public function setItems(&$items) : void { $this->items = $items; $this->totalItems = sizeof($items); } }