Created
August 12, 2015 01:15
-
-
Save chukShirley/d8270d02d39e79cfffde to your computer and use it in GitHub Desktop.
value object for unique key containing multiple columns
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
class CustomerId | |
{ | |
private $name; | |
private $address; | |
public function __construct($name, $address) | |
{ | |
$this->name = (string) $name; | |
$this->address = (string) $address; | |
} | |
public function getName() | |
{ | |
return $this->name; | |
} | |
public function getAddress() | |
{ | |
return $this->address; | |
} | |
public function isEqual(CustomerId $customerId) | |
{ | |
if ($this->name !== $customerId->getName()) | |
{ | |
return false; | |
} | |
if ($this->address !== $customerId->getAddress()) | |
{ | |
return false; | |
} | |
return true; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment