-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #2109 from MTES-MCT/hotfix/2107-fix-commande-updat…
…e-communes [bug] La commande de maj des commune ne dépends plus des fixtures
- Loading branch information
Showing
3 changed files
with
37 additions
and
30 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
<?php | ||
|
||
namespace App\Utils; | ||
|
||
class ImportCommune | ||
{ | ||
// File found here: https://www.data.gouv.fr/fr/datasets/codes-postaux/ | ||
public const COMMUNE_LIST_CSV_PATH = '/src/DataFixtures/Files/codespostaux.csv'; | ||
|
||
public const INDEX_CSV_CODE_POSTAL = 0; | ||
public const INDEX_CSV_CODE_COMMUNE = 1; | ||
public const INDEX_CSV_NOM_COMMUNE = 2; | ||
|
||
public static function getZipCodeByCodeCommune($itemCodeCommune) | ||
{ | ||
$codeCommune = $itemCodeCommune; | ||
$codeCommune = str_pad($codeCommune, 5, '0', \STR_PAD_LEFT); | ||
$zipCode = substr($codeCommune, 0, 2); | ||
if ('97' == $zipCode) { | ||
$zipCode = substr($codeCommune, 0, 3); | ||
} | ||
|
||
return $zipCode; | ||
} | ||
} |