public function add_attribute(Attribute $attribute) { if (isset($this->attributes[$attribute->name()])) { throw new Exception("duplicate attribute {$attribute->name()}"); } $this->attributes[$attribute->name()] = $attribute; }