/**
  * Adds an attribute field.
  *
  * @param   AttributeMetadata   $attribute
  * @return  self
  * @throws  MetadataException   If the attribute key already exists as a relationship.
  */
 public function addAttribute(AttributeMetadata $attribute)
 {
     if (isset($this->relationships[$attribute->getKey()])) {
         throw MetadataException::fieldKeyInUse('attribute', 'relationship', $attribute->getKey(), $this->type);
     }
     $this->attributes[$attribute->getKey()] = $attribute;
     ksort($this->attributes);
     return $this;
 }