Skip to content

Instantly share code, notes, and snippets.

@chukShirley
Created August 12, 2015 01:15
Show Gist options
  • Save chukShirley/d8270d02d39e79cfffde to your computer and use it in GitHub Desktop.
Save chukShirley/d8270d02d39e79cfffde to your computer and use it in GitHub Desktop.
value object for unique key containing multiple columns
<?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