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()); } }
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()); }
/** * {@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); }
public function setAddress(AddressInterface $address) { $this->setCellMargins("", "", "", ""); $this->SetFont(self::FONT); $this->SetFont(self::FONT_BOLD); if ($address->getCompany()) { $this->MultiCell(self::ADDRESS_WIDTH, 0, $address->getCompany(), 0, "L", false, 1, self::MARGIN_LEFT, self::MARGIN_TOP); $this->MultiCell(self::ADDRESS_WIDTH, 0, $address->getFirstName(), 0, "L", false, 1, self::MARGIN_LEFT); } else { $this->MultiCell(self::ADDRESS_WIDTH, 0, $address->getFirstName(), 0, "L", false, 1, self::MARGIN_LEFT, self::MARGIN_TOP); } $this->MultiCell(self::ADDRESS_WIDTH, 0, $address->getStreet(), 0, "L", false, 1, self::MARGIN_LEFT); $this->MultiCell(self::ADDRESS_WIDTH, 0, $address->getPostcode(), 0, "L", false, 1, self::MARGIN_LEFT); $country = $address->getCountryCode(); $this->MultiCell(self::ADDRESS_WIDTH, 0, $country, 0, "L", false, 1, self::MARGIN_LEFT); if (!$address->getCompany()) { $this->MultiCell(self::ADDRESS_WIDTH, 0, "", 0, "L", false, 1, self::MARGIN_LEFT); } }
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); }
/** * @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()]); }