Values = $values; } /** * @inheritDoc */ public function Serialize (): string { return serialize($this->Values); } /** * @inheritDoc */ public function UnSerialize (string $serialized): void { $this->Values = unserialize($serialized); } /** * @inheritDoc */ public function offsetExists (mixed $offset): bool { return isset($this->Values[$offset]); } /** * @inheritDoc */ public function offsetGet (mixed $offset): mixed { // Если ключ не является целым числом if (!is_int($offset)) // - возвращаем null return null; // Возвращаем значение кортежа по индексу return $this->Get($offset); } /** * Возвращает значение кортежа по индексу. * * @param int $index Индекс значения. * * @return mixed Значение кортежа по индексу. */ public function Get (int $index): mixed { return $this->Values[$index] ?? null; } /** * @inheritDoc * @throws Exception Элементы кортежа не могут быть изменены после создания! / Tuple elements cannot be changed * after creation! */ public function offsetSet (mixed $offset, mixed $value): void { throw new Exception('Элементы кортежа не могут быть изменены после создания! / Tuple elements cannot be changed after creation!'); } /** * @inheritDoc */ public function offsetUnset (mixed $offset): void { unset($this->Values[$offset]); } /** * @inheritDoc */ public function getIterator (): Traversable { return new ArrayIterator($this->Values); } /** * @inheritDoc */ public function count (): int { return count($this->Values); } }