Skip to content

Commit

Permalink
Merge pull request #121 from vibko/add-pt-crn
Browse files Browse the repository at this point in the history
Adding a PT company registration number
  • Loading branch information
vibko committed Jul 7, 2023
2 parents 9e4240f + ab1f5d2 commit 0a3fb23
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 1 deletion.
15 changes: 14 additions & 1 deletion src/CompanyRegistrationNumber.php
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,8 @@ private function isValid(
$this->isValidCH($value) ||
$this->isValidDE($value) ||
$this->isValidHR($value) ||
$this->isValidNL($value);
$this->isValidNL($value) ||
$this->isValidPT($value);
}

private function isValidCH(
Expand Down Expand Up @@ -315,4 +316,16 @@ private function isValidNL(
return (bool) \preg_match('#^(\d{9}B\d{2}|\d{8})$#', $value);
}

private function isValidPT(
string $value
): bool {
$value = (string) \preg_replace(
'#\s+#',
'',
$value
);

return (bool) \preg_match('#^\d{9}$#', $value);
}

}
1 change: 1 addition & 0 deletions tests/CompanyRegistrationNumberTest.phpt
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,7 @@ final class CompanyRegistrationNumberTest extends TestCase
'32145678934', //HR
'33127977', // NL
'001632553B28', // NL
'500271615', // PT
];

foreach ($validValues as $validValue) {
Expand Down

0 comments on commit 0a3fb23

Please sign in to comment.