data); } /** * Offset to retrieve * * @link https://php.net/manual/en/arrayaccess.offsetget.php * @param mixed $offset
The offset to retrieve.
* @return mixed Can return all value types. */ public function offsetGet(mixed $offset): mixed { return array_key_exists($offset, $this->data) ? $this->data[$offset] : throw new AssertionFailedError(sprintf("Example %s doesn't exist", $offset)); } /** * Offset to set * * @link https://php.net/manual/en/arrayaccess.offsetset.php * @param mixed $offsetThe offset to assign the value to.
* @param mixed $valueThe value to set.
*/ public function offsetSet(mixed $offset, mixed $value): void { $this->data[$offset] = $value; } /** * Offset to unset * * @link https://php.net/manual/en/arrayaccess.offsetunset.php * @param mixed $offsetThe offset to unset.
*/ public function offsetUnset(mixed $offset): void { unset($this->data[$offset]); } /** * Count elements of an object * * @link https://php.net/manual/en/countable.count.php * @return int The custom count as an integer. * The return value is cast to an integer. */ public function count(): int { return count($this->data); } /** * Retrieve an external iterator * * @link https://php.net/manual/en/iteratoraggregate.getiterator.php * @return Traversable An instance of an object implementing Iterator or Traversable */ public function getIterator(): Traversable { return new ArrayIterator($this->data); } }