From 61f5930108a68f21458332178a8e56d048bdea2d Mon Sep 17 00:00:00 2001 From: Brian Faust Date: Mon, 2 Sep 2024 12:28:44 +0300 Subject: [PATCH 1/2] Support for 7-digit postal codes in Egypt Then new Egypt Postal code system depends on assigning 7 digit postal code number to every block of buildings, which assure better accuracy of identifying the postal code. https://epostalmap.com/en/ --- src/Formatter/EGFormatter.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Formatter/EGFormatter.php b/src/Formatter/EGFormatter.php index ecbf988..ffa9bd6 100644 --- a/src/Formatter/EGFormatter.php +++ b/src/Formatter/EGFormatter.php @@ -21,7 +21,7 @@ class EGFormatter implements CountryPostcodeFormatter */ public function format(string $postcode) : ?string { - if (preg_match('/^[0-9]{5}$/', $postcode) !== 1) { + if (preg_match('/^\d{5}(\d{2})?$/', $postcode) !== 1) { return null; } From 5d432125716d98cd9f352183c2e9094c00c4ed6f Mon Sep 17 00:00:00 2001 From: Brian Faust Date: Sun, 15 Sep 2024 13:16:20 +0300 Subject: [PATCH 2/2] Add reference to UPU specification --- src/Formatter/EGFormatter.php | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/Formatter/EGFormatter.php b/src/Formatter/EGFormatter.php index ffa9bd6..afecae8 100644 --- a/src/Formatter/EGFormatter.php +++ b/src/Formatter/EGFormatter.php @@ -9,10 +9,11 @@ /** * Validates and formats postcodes in Egypt. * - * Postcodes consist of 5 digits, without separator. + * Postcodes consist of 5 or 7 digits, without separator. * * @see https://en.wikipedia.org/wiki/List_of_postal_codes * @see https://en.wikipedia.org/wiki/List_of_postal_codes_in_Egypt + * @see https://www.upu.int/UPU/media/upu/PostalEntitiesFiles/addressingUnit/egyEn.pdf */ class EGFormatter implements CountryPostcodeFormatter {