CommerceGuys\Zone\Model\ZoneInterface::match PHP Method

match() public method

Checks whether the provided address belongs to the zone.
public match ( CommerceGuys\Addressing\AddressInterface $address ) : boolean
$address CommerceGuys\Addressing\AddressInterface The address.
return boolean True if the provided address belongs to the zone, false otherwise.
    public function match(AddressInterface $address);

Usage Example

 /**
  * Checks whether the store is registered to collect taxes in the given zone.
  *
  * @param ZoneInterface $zone    The zone.
  * @param Context       $context The context containing store information.
  *
  * @return bool True if the store is registered to collect taxes in the
  *              given zone, false otherwise.
  */
 protected function checkStoreRegistration(ZoneInterface $zone, Context $context)
 {
     $storeRegistrations = $context->getStoreRegistrations();
     foreach ($storeRegistrations as $country) {
         if (!isset($this->emptyAddresses[$country])) {
             $this->emptyAddresses[$country] = new Address($country);
         }
         if ($zone->match($this->emptyAddresses[$country])) {
             return true;
         }
     }
     return false;
 }
All Usage Examples Of CommerceGuys\Zone\Model\ZoneInterface::match