Пример #1
0
 /**
  * Returns the location for given zip code
  * @param string $zipCode
  *
  * @return Region
  *
  * @throws ResourceNotFoundException
  */
 public function getLocationForZip($zipCode)
 {
     $zipCode = $this->getSanitizeZipCode($zipCode);
     /*
      * In france the Zone Zip-code can be two or three digits if not found with two try with three
      * Example: Corse du sud (2A) == 200 && 201
      *          Guyane == 973
      */
     $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));
     }
 }
 /**
  * test to get all values
  */
 public function testGetAll()
 {
     $r = new AreaRepository();
     $this->assertContainsOnlyInstancesOf('EBT\\GeoZipLocation\\Translator\\BE\\Location\\Area', $r->getAll());
 }