* @template-implements ICollection */ class Collection extends ImmutableCollection implements ICollection { /** * @inheritDoc */ public function set ($key, $value): self { return $this->_set($key, $value); } /** * @inheritDoc */ public function add ($value): self { $this->elements[] = $value; return $this; } /** * @inheritDoc */ public function clear (): self { $this->_initialize(); return $this; } /** * @inheritDoc */ public function remove ($key): self { unset($this->elements[$this->_normalizeKey($key)]); return $this; } /** * @inheritDoc */ public function removeValue ($value, bool $strict = false): self { foreach ($this->elements as $currentKey => $currentValue) { if (($strict && $value === $currentValue) || (!$strict && $value == $currentValue)) { unset($this->elements[$currentKey]); } } return $this; } /** * @inheritDoc */ public function offsetSet ($offset, $value): void { $this->set($offset, $value); } /** * @inheritDoc */ public function offsetUnset ($offset): void { $this->remove($offset); } }