mirror of
https://github.com/DesignPatternsPHP/DesignPatternsPHP.git
synced 2025-06-28 20:23:34 +02:00
Merge pull request #231 from FatBoyXPC/dry-datamapper
DRY things up a bit
This commit is contained in:
@ -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;
|
||||
|
||||
|
@ -33,9 +33,9 @@ class User
|
||||
*/
|
||||
public function __construct($id = null, $username = null, $email = null)
|
||||
{
|
||||
$this->userId = $id;
|
||||
$this->username = $username;
|
||||
$this->email = $email;
|
||||
$this->setUserID($id);
|
||||
$this->setUsername($username);
|
||||
$this->setEmail($email);
|
||||
}
|
||||
|
||||
/**
|
||||
|
Reference in New Issue
Block a user