mirror of
https://github.com/DesignPatternsPHP/DesignPatternsPHP.git
synced 2025-07-09 09:34:46 +02:00
DRY more things!
This commit is contained in:
@ -22,8 +22,7 @@ class Value implements ValueInterface
|
|||||||
*/
|
*/
|
||||||
public function __construct(Attribute $attribute)
|
public function __construct(Attribute $attribute)
|
||||||
{
|
{
|
||||||
$attribute->addValue($this);
|
$this->setAttribute($attribute);
|
||||||
$this->attribute = $attribute;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -33,7 +32,7 @@ class Value implements ValueInterface
|
|||||||
*/
|
*/
|
||||||
public function setAttribute(Attribute $attribute)
|
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
|
$attribute->addValue($this); // Add value to new attribute
|
||||||
$this->attribute = $attribute;
|
$this->attribute = $attribute;
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user