From 118c37adabd58e5774517957235f11f0db5de9d7 Mon Sep 17 00:00:00 2001 From: James LaChance Date: Sun, 18 Sep 2016 12:54:11 -0400 Subject: [PATCH] DRY more things! --- More/EAV/Value.php | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/More/EAV/Value.php b/More/EAV/Value.php index 2c156a9..da4370f 100644 --- a/More/EAV/Value.php +++ b/More/EAV/Value.php @@ -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;