Returns an array of translated address fields
@param array $address
@param boolean $both
@return array
483738
public function getTranslated(array $address, $both = false)
    {
        $default = $this->country->getDefaultFormat();
        $format = gplcart_array_merge($default, $address['country_format']);

        gplcart_array_sort($format);

        $results = array();
        foreach ($format as $key => $data) {

            if (!array_key_exists($key, $address) || empty($data['status'])) {
                continue;
            }

            if ($key === 'country') {
                $address[$key] = $address['country_native_name'];
            }

            if ($key === 'state_id') {
                $address[$key] = $address['state_name'];
            }

            if ($key === 'city_id' && !empty($address['city_name'])) {
                $address[$key] = $address['city_name'];
            }

            if ($both) {
                $results[$data['name']] = $address[$key];
                continue;
            }

            $results[$key] = $address[$key];
        }

        return array_filter($results);
    }
119705
public function deleteAddress(Address $address)
    {
        if ($this !== $address->addressable()->first())
            return false;

        return $address->delete();
    }
1010434
protected function formatAddress($address)
    {
        if (is_array($address)) {
            $email = is_int(key($address)) ? current($address) : key($address);
            return array($email => current($address));
        }

        return array($address => $address);
    }
1222343
protected function _splitAddresses($address)
    {
        if (!empty($this->limit) && count($this->addresses) == $this->limit) {
            return '';
        }

        if ($this->_isGroup($address) && !isset($this->error)) {
            $split_char = ';';
            $is_group   = true;
        } elseif (!isset($this->error)) {
            $split_char = ',';
            $is_group   = false;
        } elseif (isset($this->error)) {
            return false;
        }

        // Split the string based on the above ten or so lines.
        $parts  = explode($split_char, $address);
        $string = $this->_splitCheck($parts, $split_char);

        // If a group...
        if ($is_group) {
            // If $string does not contain a colon outside of
            // brackets/quotes etc then something's fubar.

            // First check there's a colon at all:
            if (strpos($string, ':') === false) {
                $this->error = 'Invalid address: ' . $string;
                return false;
            }

            // Now check it's outside of brackets/quotes:
            if (!$this->_splitCheck(explode(':', $string), ':')) {
                return false;
            }

            // We must have a group at this point, so increase the counter:
            $this->num_groups++;
        }

        // $string now contains the first full address/group.
        // Add to the addresses array.
        $this->addresses[] = array(
                                   'address' => trim($string),
                                   'group'   => $is_group
                                   );

        // Remove the now stored address from the initial line, the +1
        // is to account for the explode character.
        $address = trim(substr($address, strlen($string) + 1));

        // If the next char is a comma and this was a group, then
        // there are more addresses, otherwise, if there are any more
        // chars, then there is another address.
        if ($is_group && substr($address, 0, 1) == ','){
            $address = trim(substr($address, 1));
            return $address;

        } elseif (strlen($address) > 0) {
            return $address;

        } else {
            return '';
        }

        // If you got here then something's off
        return false;
    }
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;
    }
398246
public function getZonesFromAddress(AddressInterface $address)
    {
        return $this
            ->zoneRepository
            ->getActiveZones()
            ->filter(function (ZoneInterface $zone) use ($address) {

                return $this
                    ->zoneMatcher
                    ->isAddressContainedInZone(
                        $address,
                        $zone
                    );
            });
    }
445727
protected function formatAddress($address, $port)
    {
        if ($port !== 0) {
            if (strpos($address, ':') !== false) {
                $address = '[' . $address . ']';
            }
            $address .= ':' . $port;
        }
        return $address;
    }
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);
  }
722672
function getCache($address) {
        if(!isset($this->dsn))
            return false;
        
        $_ret = array();
        
        // PEAR DB
        require_once('DB.php');          
        $_db =& DB::connect($this->dsn);
        if (PEAR::isError($_db)) {
            die($_db->getMessage());
        }
        $_res =& $_db->query("SELECT lon,lat FROM {$this->_db_cache_table} where address = ?", $address);
        if (PEAR::isError($_res)) {
            die($_res->getMessage());
        }
        if($_row = $_res->fetchRow()) {            
            $_ret['lon'] = $_row[0];
            $_ret['lat'] = $_row[1];
        }
        
        $_db->disconnect();
        
        return !empty($_ret) ? $_ret : false;
    }
647681
protected function mapAddressListToArray(Mail\AddressList $addresses, $type = 'to')
    {
        $array = [];
        /** @var Mail\Address() $address */
        foreach ($addresses as $address) {
            $array[] = [
                'email' => $address->getEmail(),
                'name' => $address->getName(),
                'type' => $type
            ];
        }
        return $array;
    }
630026
private function adaptAddresses(array $addresses): array
    {
        $adapted = [];
        foreach ($addresses as $address) {
            if ($address->name() !== null) {
                $adapted[$address->email()] = $address->name();
            } else {
                $adapted[] = $address->email();
            }
        }

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

        return $this;
    }
1319141
public function address(array $address)
    {
        if (! isset($this->data->addresses)) {
            $this->data->addresses = [];
        }

        return $this->data->addresses[] = (object) $address;
    }
309528
protected function prepareListAddress(array &$addresses)
    {
        foreach ($addresses as &$address) {
            $address['translated'] = $this->address->getTranslated($address, true);
        }
    }
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;
    }
353001
private function getAddressesFromFieldInPart($field, Part $part)
    {
        $addresses = [];

        $headers = $part->getHeaders();
        if (empty($headers)) {
            return $addresses;
        }

        if (!$headers->has($field)) {
            return $addresses;
        }

        /** @var AbstractAddressList $addressList */
        $addressList = null;

        try {
            $addressList = $part->getHeader($field);
        } catch (InvalidArgumentException $e) {
            return $addresses;
        }

        if (!$addressList instanceof AbstractAddressList) {
            return $addresses;
        }

        foreach ($addressList->getAddressList() as $address) {
            $addresses[] = strtolower($address->getEmail());
        }

        return $addresses;
    }
226018
public function retrieve($address) {
		/** @var \Geo\Model\Entity\GeocodedAddress $entity */
		$entity = $this->find()->where(['address' => $address])->first();
		if ($entity) {
			return $entity;
		}

		$result = $this->_execute($address);
		$address = $this->newEntity([
			'address' => $address
		]);
		if ($result) {
			$address->lat = $result->getLatitude();
			$address->lng = $result->getLongitude();
			$address->country = $result->getCountry()->getCode();

			$formatter = new StringFormatter();
			$address->formatted_address = $formatter->format($result, '%S %n, %z %L');
			$address->data = $result;
		}

		return $this->save($address);
	}