Skip to content

Commit 0723428

Browse files
committed
Support 6-digit postcodes in PY
1 parent 8ef37e5 commit 0723428

File tree

2 files changed

+4
-3
lines changed

2 files changed

+4
-3
lines changed

src/Formatter/PYFormatter.php

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -11,16 +11,15 @@
1111
/**
1212
* Validates and formats postcodes in Paraguay.
1313
*
14-
* Postcodes consist of 4 digits, without separator.
14+
* Postcodes consist of 4 digits before June 2018 and 6 digits thereafter, without a separator.
1515
*
1616
* @see https://en.wikipedia.org/wiki/List_of_postal_codes
17-
* @see https://en.wikipedia.org/wiki/List_of_postal_codes_of_Paraguay
1817
*/
1918
final class PYFormatter implements CountryPostcodeFormatter
2019
{
2120
public function format(string $postcode): ?string
2221
{
23-
if (preg_match('/^[0-9]{4}$/', $postcode) !== 1) {
22+
if (preg_match('/^(?:[0-9]{4}|[0-9]{6})$/', $postcode) !== 1) {
2423
return null;
2524
}
2625

tests/Formatter/PYFormatterTest.php

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,8 @@ public function providerFormat(): array
2323
['123', null],
2424
['1234', '1234'],
2525
['12345', null],
26+
['123456', '123456'],
27+
['1234567', null],
2628

2729
['A', null],
2830
['AB', null],

0 commit comments

Comments
 (0)