Skip to content

Instantly share code, notes, and snippets.

@chukShirley
Created November 4, 2015 22:32
Show Gist options
  • Save chukShirley/263775ae40cd33eba501 to your computer and use it in GitHub Desktop.
Save chukShirley/263775ae40cd33eba501 to your computer and use it in GitHub Desktop.
PHP Value Objects
<?php
namespace My\Namespace;
final class InvoiceNumber
{
private $invoiceNumber;
private function __construct(){};
public static function fromString($string)
{
$invoiceNumber = new InvoiceNumber();
$invoiceNumber->invoiceNumber = (string) $string;
return $invoiceNumber;
}
public function getInvoiceNumber()
{
return $this->invoiceNumber;
}
public function equals(InvoiceNumber $invoiceNumber)
{
return $invoiceNumber->getInvoiceNumber === $this->getInvoiceNumber();
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment