diff --git a/src/Validator.php b/src/Validator.php index bac22e5..12e7770 100644 --- a/src/Validator.php +++ b/src/Validator.php @@ -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; @@ -113,7 +112,7 @@ public function validateVatNumberFormat(string $vatNumber, bool $skipIfUnsupport $number = substr($vatNumber, 2); if (! isset($this->patterns[$country])) { - return $skipIfUnsupported; + throw new \InvalidArgumentException('The vat country prefix is not supported.'); } return preg_match('/^' . $this->patterns[$country] . '$/', $number) > 0; diff --git a/tests/ValidatorTest.php b/tests/ValidatorTest.php index 847bc49..b4fb3f3 100644 --- a/tests/ValidatorTest.php +++ b/tests/ValidatorTest.php @@ -96,14 +96,6 @@ public function testValidateVatNumberFormat() 'SI1234567', 'SK123456789', - // valid number but with prefix - 'invalid_prefix_GB999999973', - 'invalid_prefix_IE1234567X', - 'invalid_prefix_ESB1234567C', - 'invalid_prefix_BE0123456789', - 'invalid_prefix_MT12345678', - 'invalid_prefix_LT123456789', - // valid number but with suffix 'IE1234567X_invalid_suffix', 'ESB1234567C_invalid_suffix',