Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Adding a PT company registration number #121

Merged
merged 1 commit into from
Jul 7, 2023
Merged
Show file tree
Hide file tree
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
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
Loading