/** * Returns the location for given zip code * * @param string $zipCode * * @return Region * * @throws \EBT\GeoZipLocation\Exception\ResourceNotFoundException* */ public function getLocationForZip($zipCode) { $zipCode = $this->getSanitizeZipCode($zipCode); if (false !== $zipCode && isset($this->map[$zipCode])) { $area = $this->repo_area->getById($this->map[$zipCode][self::DATA_INDEX_AREA]); $zone = $this->repo_zone->getById($this->map[$zipCode][self::DATA_INDEX_ZONE]); $region = $this->repo_region->getById($this->map[$zipCode][self::DATA_INDEX_REGION]); $zone->setSubLocation($area); $region->setSubLocation($zone); return $region; } else { throw new ResourceNotFoundException(sprintf('Unable to find a region for %s zipcode', $zipCode)); } }