Checks whether the provided address belongs to the zone.

@param \CommerceGuys\Addressing\AddressInterface $address The address.

@return bool True if the provided address belongs to the zone, false otherwise.
965613
public function match(AddressInterface $address)
    {
        foreach ($this->territories as $territory) {
            if ($territory->match($address)) {
                return true;
            }
        }
        return false;
    }
572469
public function isZone($zones)
    {
        $zone = $this->getZone();

        return is_array($zones) ? in_array($this->getZone(), $zones, true) : $zone === $zones;
    }
972431
private function validateAddress($address) {
		ArgUtils::valType($address, 'scalar');
		
		$email = self::stripEmail($address);
		
		if (!filter_var($email, FILTER_VALIDATE_EMAIL)) throw new MailFormatException('invalid e-mail address: ' . $address);
	}
657219
public function geolocateIPAddress(AddressInterface $address)
    {
        $result = new GeolocationResult();
        try {
            switch ($address->getRangeType()) {
                case IPRangeType::T_PUBLIC:
                    $addressString = (string) $address;
                    $session = $this->app->make('session');
                    $sessionKey = 'ccm/geolocation/' . $this->geolocator->getGeolocatorHandle() . '/' . $this->geolocator->getGeolocatorID() . '/' . md5(serialize($this->geolocator->getGeolocatorConfiguration())) . '/' . $addressString;
                    if ($session->has($sessionKey)) {
                        $result = $session->get($sessionKey);
                    } else {
                        $result = $this->performGeolocation($address);
                        $session->set($sessionKey, $result);
                    }
                    break;
                default:
                    $result->setError(GeolocationResult::ERR_IPNOTPUBLIC);
                    break;
            }
        } catch (Exception $x) {
            $result->setError(GeolocationResult::ERR_OTHER, '', $x);
        } catch (Throwable $x) {
            $result->setError(GeolocationResult::ERR_OTHER, '', new Exception($x->getMessage(), $x->getCode()));
        }

        return $result;
    }
813822
public static function locate($address)
	{
		$ip = false;
		if (filter_var($address, FILTER_VALIDATE_IP))
		{
			$ip = true;
		}

		$adapter  = new \Geocoder\HttpAdapter\CurlHttpAdapter();

		$p = array();

		// Get a list of providers
		if ($providers = \Event::trigger('geocode.onGeocodeProvider', array('geocode.locate', $adapter, $ip)))
		{
			foreach ($providers as $provider)
			{
				if ($provider)
				{
					$p[] = $provider;
				}
			}
		}

		if (!count($p))
		{
			return '';
		}

		// Instantiate the Geocoder service and pass it the list of providers
		$geocoder = new \Geocoder\Geocoder();
		$geocoder->registerProvider(new \Geocoder\Provider\ChainProvider($p));

		// Try to get some data...
		return $geocoder->geocode($address);
	}
186235
public function getIpNumberFromAddress($address)
    {
        // Unrecognised addresses cause PHP warnings, silence the warning and return a bool instead
        $pton = @inet_pton($address);
        if (!$pton) {
            return false;
        }

        $number = '';
        foreach (unpack('C*', $pton) as $byte) {
            $number .= str_pad(decbin($byte), 8, '0', STR_PAD_LEFT);
        }

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

        return $this;
    }
1073447
public function getAddressType(AddressInterface $address)
    {
        $result = null;
        if ($this->range->contains($address)) {
            foreach ($this->exceptions as $exception) {
                $result = $exception->getAddressType($address);
                if ($result !== null) {
                    break;
                }
            }
            if ($result === null) {
                $result = $this->type;
            }
        }

        return $result;
    }
531444
public function addAddress($address)
    {
        if (!$this->getAddresses()) {
            return $this->setAddresses(array($address));
        } else {
            return $this->setAddresses(
                array_merge($this->getAddresses(), array($address))
            );
        }
    }
1137980
public function setAddress(Address $address)
    {
        $address->setContext(Moip::SUBSCRIPTION);
        $this->data->address = $address->getData();

        return $this;
    }
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;
    }
264595
public function setAddress(string $address = null) : void
    {
        if (!is_null($address) && !filter_var($address, FILTER_VALIDATE_IP, FILTER_FLAG_IPV4 | FILTER_FLAG_IPV6)) {
            Utils::getContainer()->getLogger()->warning(sprintf('Provided argument (%s) is not a valid IP address.', $address));
        }
        $this->Address = $address;
    }
1183187
public function getCoordinatesByString(string $address) : CoordinatesInterface
    {
        $url = $this->addressQuery($address);
        $json = $this->fetchUrl($url);

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

        return $coordinates;
    }
1280050
public function cleanCustomerAddress(array $address) {
    if (isset($address['customer_address_id']) && empty($address['address_id'])) {
      $address['address_id'] = $address['customer_address_id'];
    }

    return $this->cleanAddress($address);
  }
524070
private function cleanAddress($address, $updatableFields)
    {
        if (is_array($address)) {
            /** @var UpdatableFieldsConstructor $updatableFieldsConstructor */
            $updatableFieldsConstructor = oxNew(UpdatableFieldsConstructor::class);
            $cleaner = $updatableFieldsConstructor->getAllowedFieldsCleaner($updatableFields);
            return $cleaner->filterByUpdatableFields($address);
        }

        return $address;
    }
707613
public function sameValueAs(ValueObjectInterface $address)
    {
        if (false === Util::classEquals($this, $address)) {
            return false;
        }

        return $this->getName()->sameValueAs($address->getName())             &&
               $this->getStreet()->sameValueAs($address->getStreet())         &&
               $this->getDistrict()->sameValueAs($address->getDistrict())     &&
               $this->getCity()->sameValueAs($address->getCity())             &&
               $this->getRegion()->sameValueAs($address->getRegion())         &&
               $this->getPostalCode()->sameValueAs($address->getPostalCode()) &&
               $this->getCountry()->sameValueAs($address->getCountry())
        ;
    }
528733
public function setAddress($address)
    {
        if (null === $address) {
            $this->address = null;
        } elseif ('' == $address) {
            $this->address = '';
        } else {
            $this->assertValidAddress($address);
            $this->address = $address;
        }
        $this->setCachedValue(null);
    }