Example #1
0
 private function setAddress(AddressInterface $address, AddressInterface $lastOrderAddress)
 {
     if ($address->getFirstName() === null) {
         $address->setFirstName($lastOrderAddress->getFirstName());
     }
     if ($address->getLastName() === null) {
         $address->setLastName($lastOrderAddress->getLastName());
     }
     if ($address->getPhoneNumber() === null) {
         $address->setPhoneNumber($lastOrderAddress->getPhoneNumber());
     }
     if ($address->getCountryCode() === null) {
         $address->setCountryCode($lastOrderAddress->getCountryCode());
     }
     if ($address->getProvinceCode() === null) {
         $address->setProvinceCode($lastOrderAddress->getProvinceCode());
     }
     if ($address->getStreet() === null) {
         $address->setStreet($lastOrderAddress->getStreet());
     }
     if ($address->getCity() === null) {
         $address->setCity($lastOrderAddress->getCity());
     }
     if ($address->getPostcode() === null) {
         $address->setPostcode($lastOrderAddress->getPostcode());
     }
 }
Example #2
0
 public static function createAddress(AddressInterface $address)
 {
     $result = (new Address())->setStreetLines([$address->getStreet()])->setCity($address->getCity())->setPostalCode($address->getPostcode())->setCountryCode($address->getCountry()->getIsoName());
     if (null === ($province = $address->getProvince())) {
         return $result;
     }
     return $result->setStateOrProvinceCode($province->getIsoName());
 }
Example #3
0
 /**
  * {@inheritdoc}
  */
 private function specifyAddress(AddressInterface $address, $addressType)
 {
     $this->specifyElementValue($addressType . '_first_name', $address->getFirstName());
     $this->specifyElementValue($addressType . '_last_name', $address->getLastName());
     $this->specifyElementValue($addressType . '_street', $address->getStreet());
     $this->specifyElementValue($addressType . '_city', $address->getCity());
     $this->specifyElementValue($addressType . '_postcode', $address->getPostcode());
     $this->chooseCountry($address->getCountryCode(), $addressType);
 }
Example #4
0
 function it_ignores_leading_and_trailing_spaces_or_letter_cases(AddressInterface $firstAddress, AddressInterface $secondAddress)
 {
     $firstAddress->getCity()->willReturn('TOOWOOMBA');
     $firstAddress->getStreet()->willReturn('Ryans Dr     ');
     $firstAddress->getCompany()->willReturn('   Burger');
     $firstAddress->getPostcode()->willReturn(' 4350 ');
     $firstAddress->getLastName()->willReturn('jones ');
     $firstAddress->getFirstName()->willReturn('mIa');
     $firstAddress->getPhoneNumber()->willReturn(' 999');
     $firstAddress->getCountryCode()->willReturn('au');
     $firstAddress->getProvinceCode()->willReturn(null);
     $firstAddress->getProvinceName()->willReturn('qUEENSLAND');
     $secondAddress->getCity()->willReturn('Toowoomba');
     $secondAddress->getStreet()->willReturn('Ryans Dr');
     $secondAddress->getCompany()->willReturn('Burger');
     $secondAddress->getPostcode()->willReturn('4350');
     $secondAddress->getLastName()->willReturn('Jones');
     $secondAddress->getFirstName()->willReturn('Mia');
     $secondAddress->getPhoneNumber()->willReturn('999');
     $secondAddress->getCountryCode()->willReturn('AU');
     $secondAddress->getProvinceCode()->willReturn(null);
     $secondAddress->getProvinceName()->willReturn('Queensland');
     $this->equal($firstAddress, $secondAddress)->shouldReturn(true);
 }
Example #5
0
 /**
  * @param AddressInterface $address
  *
  * @return array
  */
 private function normalizeAddress(AddressInterface $address)
 {
     return array_map(function ($value) {
         return trim(strtolower($value));
     }, [$address->getCity(), $address->getCompany(), $address->getCountryCode(), $address->getFirstName(), $address->getLastName(), $address->getPhoneNumber(), $address->getPostcode(), $address->getProvinceCode(), $address->getProvinceName(), $address->getStreet()]);
 }