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();
}
}