Skip to content

Instantly share code, notes, and snippets.

@Steerlin
Created January 16, 2015 14:23
Show Gist options
  • Save Steerlin/224e2701fce380d82a5a to your computer and use it in GitHub Desktop.
Save Steerlin/224e2701fce380d82a5a to your computer and use it in GitHub Desktop.
<?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