properties = $properties; $this->readOnly = $readOnly; } public function getIterator() { return new ArrayIterator($this->properties); } public function offsetGet($key) { if (!array_key_exist($key, $this->properties)) { throw new InvalidArgumentException("No such property: {$key}"); } return $this->properties[$key]; } public function offsetSet($key, $value) { if ($this->readOnly) { return; } $this->properties[$key] = $value; } public function offsetUnset($key) { if ($this->readOnly) { return; } unset($this->properties[$key]); } public function offsetExists($key) { return array_key_exists($key, $this->properties); } public function count() { return count($this->properties); } }