Example #1
0
 /**
  * Checks if address belongs to particular zone member.
  *
  * @param AddressInterface    $address
  * @param ZoneMemberInterface $member
  *
  * @return Boolean
  *
  * @throws \InvalidArgumentException
  */
 protected function addressBelongsToZoneMember(AddressInterface $address, ZoneMemberInterface $member)
 {
     $type = $member->getBelongsTo()->getType();
     switch ($type) {
         case ZoneInterface::TYPE_PROVINCE:
             return null !== $address->getProvince() && $address->getProvince() === $member->getProvince();
         case ZoneInterface::TYPE_COUNTRY:
             return null !== $address->getCountry() && $address->getCountry() === $member->getCountry();
         case ZoneInterface::TYPE_ZONE:
             return $this->addressBelongsToZone($address, $member->getZone());
         default:
             throw new \InvalidArgumentException(sprintf('Unexpected zone type "%s".', $type));
     }
 }