Skip to content

Commit

Permalink
Throw exception
Browse files Browse the repository at this point in the history
  • Loading branch information
VincentLanglet committed Jan 29, 2024
1 parent e5b758c commit 235d6a9
Showing 1 changed file with 3 additions and 4 deletions.
7 changes: 3 additions & 4 deletions src/Validator.php
Original file line number Diff line number Diff line change
Expand Up @@ -98,11 +98,10 @@ public function hasSupportedCountryPrefix(string $vatNumber): bool
* Validate a VAT number format. This does not check whether the VAT number was really issued.
*
* @param string $vatNumber
* @param bool $skipIfUnsupported
*
* @return boolean
*/
public function validateVatNumberFormat(string $vatNumber, bool $skipIfUnsupported = false): bool
public function validateVatNumberFormat(string $vatNumber): bool
{
if ($vatNumber === '') {
return false;
Expand All @@ -112,8 +111,8 @@ public function validateVatNumberFormat(string $vatNumber, bool $skipIfUnsupport
$country = substr($vatNumber, 0, 2);
$number = substr($vatNumber, 2);

if (! isset($this->patterns[$country])) {
return $skipIfUnsupported;
if (! isset($this->patterns[$country]) {
throw new \InvalidArgumentException('The vat country prefix is not supported.');
}

return preg_match('/^' . $this->patterns[$country] . '$/', $number) > 0;
Expand Down

0 comments on commit 235d6a9

Please sign in to comment.