Skip to content

Instantly share code, notes, and snippets.

@bobthecow
Created February 7, 2011 20:10
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save bobthecow/815088 to your computer and use it in GitHub Desktop.
Save bobthecow/815088 to your computer and use it in GitHub Desktop.
<?php
// unit test:
foreach(array(Order::BILLING, Order::SHIPPING) as $type){
${$type."Address"} = new CustomerAddress();
${$type."Address"}->setFirstName("{$type} First");
${$type."Address"}->setLastName("{$type} Last");
${$type."Address"}->setAddress1("{$type} 123 Main Street");
${$type."Address"}->setAddress2("{$type} Apt 123");
${$type."Address"}->setCity("{$type} New York");
${$type."Address"}->setState("{$type} NY");
${$type."Address"}->setPostalCode("{$type} 10011");
}
$order->setShippingAddress($shippingAddress);
$order->setBillingAddress($billingAddress);
// Order.php
public function setShippingAddress(CustomerAddress $address)
{
$this->shippingName = sprintf("%s %s", $address->getFirstName(), $address->getLastName());
$this->shippingAddress1 = $address->getAddress1();
$this->shippingAddress2 = $address->getAddress2();
$this->shippingCity = $address->getCity();
$this->shippingState = $address->getState();
$this->shippingPostalCode = $address->getPostalCode();
}
public function setBillingAddress(CustomerAddress $address)
{
$this->billingName = sprintf("%s %s", $address->getFirstName(), $address->getLastName());
$this->billingAddress1 = $address->getAddress1();
$this->billingAddress2 = $address->getAddress2();
$this->billingCity = $address->getCity();
$this->billingState = $address->getState();
$this->billingPostalCode = $address->getPostalCode();
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment