Adds an attribute if not already in the collection.

@param AttributeInterface $attribute Attribute

@return $this Self object
504515
public function addAttribute(AttributeInterface $attribute)
    {
        if (!$this
            ->attributes
            ->contains($attribute)) {
            $this
                ->attributes
                ->add($attribute);
        }

        return $this;
    }
72750
protected function checkAttribute(AttributeInterface $attribute)
    {
        if (!$this->getFamily()->hasAttribute($attribute->getCode())) {
            throw new MissingAttributeException(
                "Attribute {$attribute->getCode()} doesn't exists in family {$this->getFamilyCode()}"
            );
        }
        if ($attribute->getFamily() !== $this->getFamily()) {
            $m = "Attribute {$attribute->getCode()} (from family '{$attribute->getFamily()->getCode()}') doesn't ";
            $m .= "belong to this family ('{$this->getFamilyCode()}')";
            throw new MissingAttributeException($m);
        }
    }
416951
public function set($attribute, $value)
    {
        if (!$this->isImplemented($attribute)) {
            throw new Exception("PDO parameter not implemented - {$attribute}");
        }

        if ($this->hasValidator($attribute)) {
            $validator = $this->getValidator($attribute);
            $value = $this->{$validator}($value);
        }

        $this->attributes[$attribute] = $value;

        return $this;
    }
214758
public function emptyValues(AttributeInterface $attribute = null, array $context = null)
    {
        $values = $this->getInternalValues($attribute, $context);
        foreach ($values as $value) {
            $this->removeValue($value);
        }

        return $this;
    }
813901
public function attribute( $attribute, $value )
    {
        if ( null === $value )
        {
            unset( $this->attributes[ $attribute ] );
        } else {
            $this->attributes[ $attribute ] = $value;
        }

        return $this;
    }
1274541
public function withAttribute($attribute, $value)
    {
        /** @var EvolvableLinkInterface $that */
        $that = clone($this);
        $that->attributes[$attribute] = $value;
        return $that;
    }
246210
public function remove($attribute)
    {
        if (!$this->has($attribute)) {
            throw new \OutOfBoundsException("Attribute '{$attribute}' does not exist");
        }

        unset($this->attributes[$attribute]);

        return $this;
    }
752521
public function reset($attribute)
    {
        $this->batches->add(new Batch(Batch::TYPE['REMOVE_ALL'], $attribute));

        return $this;
    }
125400
protected function createDefaultValues(AttributeInterface $attribute, array $context = null)
    {
        $default = $attribute->getDefault();
        if (!$attribute->isCollection()) {
            $default = (array) $default;
        }

        return $this->setInternalValuesData($attribute, $default, $context);
    }
282873
public Attributes put(Attribute attribute) {
        Validate.notNull(attribute);
        put(attribute.getKey(), attribute.getValue());
        attribute.parent = this;
        return this;
    }
622108
public function add($attribute, ...$values)
    {
        foreach ($values as $value) {
            if ($this->has($attribute)) {
                $attribute = $this->resolveAttributeName($attribute);
                $this->attributes[$attribute] = $this->addAttributeValue($this->attributes[$attribute], $value);
            } else {
                $this->attributes[$attribute] = $value;
            }
            $this->batches->add(new Batch(Batch::TYPE['ADD'], $attribute, $value));
        }

        return $this;
    }
540209
public function addAttribute(Attribute$attribute) : Attributes
	{
		$this->getItems();//max sure is array
		$this->attributes[$attribute->getName()] = $attribute;
		return $this;
	}
470318
public function addMany(array $attributes)
    {
        if (count($attributes) > 0) {
            foreach($attributes as $name => $value) {
                $this->add($name, $value);
            }
        }

        return $this;
    }
487766
public function addAttribute(Attribute $attribute): ComplexEntity
	{
		$this->attributesCollection = $this->getAttributes()->addAttribute($attribute);
		return $this;
	}
314510
public function addAttribute($attribute)
    {
        $attributes = $this->getAttributes();
        array_push($attributes, $attribute);
        $this->setAttributes($attributes);
    }
138463
public function removeAttribute(Attribute $attribute)
    {
        foreach ($this->attributes as $key => $attributeElement) {
            if ($attributeElement === $attribute) {
                unset($this->attributes[$key]);
                break;
            }
        }

        return $this;
    }
406038
public function addAttr($attr, $val)
    {
        if (is_string($attr) === false) {
            throw new \InvalidArgumentException;
        }

        $this->attributes[$attr] = $val;

        return $this;
    }