DRY more things!

This commit is contained in:
James LaChance 2016-09-18 12:54:11 -04:00
parent 5189a7342c
commit 118c37adab

View File

@ -22,8 +22,7 @@ class Value implements ValueInterface
*/
public function __construct(Attribute $attribute)
{
$attribute->addValue($this);
$this->attribute = $attribute;
$this->setAttribute($attribute);
}
/**
@ -33,7 +32,7 @@ class Value implements ValueInterface
*/
public function setAttribute(Attribute $attribute)
{
$this->attribute->removeValue($this); // Remove value from current attribute
$this->attribute && $this->attribute->removeValue($this); // Remove value from current attribute
$attribute->addValue($this); // Add value to new attribute
$this->attribute = $attribute;