Created
January 16, 2015 14:23
-
-
Save Steerlin/224e2701fce380d82a5a to your computer and use it in GitHub Desktop.
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 | |
namespace WriteModel\Order; | |
use DateTime; | |
final class Order | |
{ | |
/** | |
* @var OrderId | |
*/ | |
private $orderId; | |
/** | |
* @var DateTime | |
*/ | |
private $placedOn; | |
/** | |
* @var string | |
*/ | |
private $customerName; | |
/** | |
* @var string | |
*/ | |
private $customerStreetAndNumber; | |
/** | |
* @var string | |
*/ | |
private $customerZipCodeAndCity; | |
/** | |
* @var string | |
*/ | |
private $customerVatNumber; | |
/** | |
* @var string | |
*/ | |
private $customerCountry; | |
private function __construct(OrderId $orderId) | |
{ | |
$this->orderId = $orderId; | |
} | |
public static function place( | |
OrderId $orderId, | |
$customerName, | |
$customerStreetAndNumber, | |
$customerZipCodeAndCity, | |
$customerCountry, | |
$customerVatNumber | |
) { | |
$order = new self($orderId); | |
$order->placedOn = new DateTime('now'); | |
$order->updateInvoiceDetails( | |
$customerName, | |
$customerStreetAndNumber, | |
$customerZipCodeAndCity, | |
$customerCountry, | |
$customerVatNumber | |
); | |
return $order; | |
} | |
public function updateInvoiceDetails( | |
$customerName, | |
$customerStreetAndNumber, | |
$customerZipCodeAndCity, | |
$customerCountry, | |
$customerVatNumber | |
) { | |
$this->customerName = $customerName; | |
$this->customerStreetAndNumber = $customerStreetAndNumber; | |
$this->customerZipCodeAndCity = $customerZipCodeAndCity; | |
$this->customerCountry = $customerCountry; | |
$this->customerVatNumber = $customerVatNumber; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment