elements[] = $property; } /** * @param string $key * @return null|Property */ public function get($name) { // Searching Property in elements-array foreach ($this->elements as $property) { if ($property->getName() == $name) { return $property; } } return null; } /** * Adds a Property. If Property already exists an Exception will be thrown. * * @param Property $property * @throws \Exception */ public function add(Property $property) { // Property already exists? if (null !== $this->get($property->getName())) { throw new \Exception("Property with name '{$property->getName()}' already exists"); } $this->elements[] = $property; } public function getIterator() { return new \ArrayObject($this->elements); } }