Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 3 additions & 2 deletions src/Formatter/EGFormatter.php
Original file line number Diff line number Diff line change
Expand Up @@ -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
{
Expand All @@ -21,7 +22,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;
}

Expand Down