Ejemplo n.º 1
0
 /**
  * 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);
     $partialZipCode = substr($zipCode, 0, 2);
     if (false !== $zipCode && isset($this->map[$partialZipCode])) {
         $area = $this->repo_area->getById($this->map[$partialZipCode][self::DATA_INDEX_AREA]);
         $zone = $this->repo_zone->getById($this->map[$partialZipCode][self::DATA_INDEX_ZONE]);
         $region = $this->repo_region->getById($this->map[$partialZipCode][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));
     }
 }
 /**
  * testGetAll
  */
 public function testGetAll()
 {
     $r = new RegionRepository();
     $this->assertContainsOnlyInstancesOf('EBT\\GeoZipLocation\\Translator\\ES\\Location\\Region', $r->getAll());
 }