Formats an address on an array.

@param AddressInterface $address The address to format

@return array
164034
public function toArray(AddressInterface $address)
    {
        $cityLocationId = $address->getCity();
        $cityHierarchy = $this
            ->locationProvider
            ->getHierarchy($cityLocationId);
        $cityHierarchyAsc = array_reverse($cityHierarchy);

        $addressArray = [
            'id' => $address->getId(),
            'name' => $address->getName(),
            'recipientName' => $address->getRecipientName(),
            'recipientSurname' => $address->getRecipientSurname(),
            'address' => $address->getAddress(),
            'addressMore' => $address->getAddressMore(),
            'postalCode' => $address->getPostalcode(),
            'phone' => $address->getPhone(),
            'mobile' => $address->getMobile(),
            'comment' => $address->getComments(),
        ];

        foreach ($cityHierarchyAsc as $cityLocationNode) {
            /**
             * @var LocationData $cityLocationNode
             */
            $addressArray['city'][$cityLocationNode->getType()]
                = $cityLocationNode->getName();
        }

        $addressArray['fullAddress'] =
            $this->buildFullAddressString(
                $address,
                $addressArray['city']
            );

        return $addressArray;
    }
200485
protected function setAddress($address)
    {
        if (is_array($address)) {
            $new_address = [];

            foreach (['address', 'city', 'state', 'zip'] as $field) {
                if (array_key_exists($field, $address)) {
                    $new_address[] = $address[$field];
                }
            }

            $address = implode(' ', $new_address);
        }

        return $address;
    }
157050
public function anonymize($address) {
        $packedAddress = inet_pton($address);

        if (strlen($packedAddress) == 4) {
            return $this->anonymizeIPv4($address);
        } elseif (strlen($packedAddress) == 16) {
            return $this->anonymizeIPv6($address);
        } else {
            return "";
        }
    }
1322199
public static function formatAddress(array $address, $sep = ', ')
    {
        $address = array_merge(
            [
                'firstname' => '',
                'lastname' => '',
                'address1' => '',
                'address2' => '',
                'address3' => '',
                'postcode' => '',
                'city' => '',
                'country_code' => '',
            ],
            $address
        );

        $values = array_map('trim', [
                sprintf('%s %s', $address['firstname'], $address['lastname']),
                $address['address1'],
                $address['address2'],
                $address['address3'],
                $address['postcode'],
                $address['city'],
            ]);

        foreach ($values as $key => $val) {
            if (!$val) {
                unset($values[$key]);
            }
        }

        $fullAddress = implode($sep, $values);

        if ($countryCode = trim($address['country_code'])) {
            if ($fullAddress) {
                $fullAddress .= ' ';
            }

            $fullAddress .= sprintf('(%s)', $countryCode);
        }

        return $fullAddress;
    }
560576
protected function formatEmailAddress($address, $title)
    {
        if (!empty($title)) {
            $address = sprintf('"%s" <%s>', $title, $address);
        }
        return $address;
    }
807146
public function cleanAddress($address)
    {
        $response = $this->query($this->prepareUri('clean/address'), [$address]);
        $result = $this->populate(new Address, $response);
        if (!$result instanceof Address) {
            throw new RuntimeException('Unexpected populate result: ' . get_class($result). '. Expected: ' . Address::class);
        }

        return $result;
    }
1045997
public function cleanAddress(array $address) {
    if (isset($address['customer_id'])) {
      $address['customer_id'] = (string) $address['customer_id'];
    }

    if (isset($address['default_billing'])) {
      $address['default_billing'] = (bool) $address['default_billing'];
    }

    if (isset($address['default_shipping'])) {
      $address['default_shipping'] = (bool) $address['default_shipping'];
    }

    return $this->normaliseExtension($address);
  }
877639
public function formatBillingAddress(ClientBillingAddress $address, $lineSeparator = self::LINES_SEPARATOR)
    {
        $lines   = [];
        $lines[] = sprintf('%s %s', $address->getFirstName(), $address->getLastName());
        if ('' !== $address->getCompanyName()) {
            $lines[] = $address->getCompanyName();
        }
        $lines[] = $address->getLine1();
        $lines[] = $address->getLine2();
        $lines[] = sprintf('%s, %s %s', $address->getCountry(), $address->getPostalCode(), $address->getCity());
        
        return implode($lineSeparator, $lines);
    }
35838
private function justAddress($address)
    {
        if (($pos = strpos($address, '<')) === false) {
            return $address;
        }

        $n = strlen($address);
        if ($address[$n - 1] == '>') {
            $address = substr($address, $pos + 1, -1);
        }

        return $address;
    }
529797
protected static function format_addresses($addresses)
	{
		$return = array();

		foreach ($addresses as $recipient)
		{
			$recipient['name'] and $recipient['email'] = '"'.$recipient['name'].'" <'.$recipient['email'].'>';
			$return[] = $recipient['email'];
		}

		return join(', ', $return);
	}
290770
public function getCoordinatesByObject(AddressInterface $address) : CoordinatesInterface
    {
        $url = $this->addressQuery($address->getFormattedAddress());
        $json = $this->fetchUrl($url);

        // convert google data to coordinates
        $coordinates = CoordinatesBuild::create($json->results[0]);

        return $coordinates;
    }
683803
private function trimAddress($address)
    {
        if (is_array($address)) {
            $fields  = oxNew(FormFields::class, $address);
            $trimmer = oxNew(FormFieldsTrimmer::class);

            $address = (array)$trimmer->trim($fields);
        }

        return $address;
    }
1011048
public function at($address)
    {
        if (AddressValidator::validate($address) === false) {
            throw new InvalidArgumentException('Please make sure address is valid.');
        }
        $this->toAddress = AddressFormatter::format($address);

        return $this;
    }
325448
public function to($address, $name = null)
    {
        if (is_array($address)) {
            $this->addAddressArray($address, 'to');
        } else {
            $this->to[$address] = $name;
        }

        return $this;
    }
764753
public function address($address) {
        $response = $this->dataClient->get($this->converter->getUrlForAddress($address));
        return $this->converter->convertAddress($response->body());
    }
918155
private function _generatorAddressCode($address)
    {
        $addressCode = array_search($address, $this->_addressCodeList);
        $classification = $this->_addressCodeClassification($addressCode);
        switch ($classification) {
            case 'country':
                $pattern = '/\d{4}(?!00)[0-9]{2}$/';
                $addressCode = $this->_getRandAddressCode($pattern);
                break;
            case 'province':
                $provinceCode = substr($addressCode, 0, 2);
                $pattern = '/^'.$provinceCode.'\d{2}(?!00)[0-9]{2}$/';
                $addressCode = $this->_getRandAddressCode($pattern);
                break;
            case 'city':
                $cityCode = substr($addressCode, 0, 4);
                $pattern = '/^'.$cityCode.'(?!00)[0-9]{2}$/';
                $addressCode = $this->_getRandAddressCode($pattern);
                break;
        }

        return $addressCode;
    }
761845
public function contains(AddressInterface $address)
    {
        $result = false;
        if ($address->getAddressType() === $this->getAddressType()) {
            $cmp = $address->getComparableString();
            $from = $this->getComparableStartString();
            if ($cmp >= $from) {
                $to = $this->getComparableEndString();
                if ($cmp <= $to) {
                    $result = true;
                }
            }
        }

        return $result;
    }