From 97178687f880da3d0fc066daa3a3a8a81917e8ae Mon Sep 17 00:00:00 2001 From: Vincent Langlet Date: Mon, 29 Jan 2024 14:55:40 +0100 Subject: [PATCH] Throw exception --- src/Validator.php | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) 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;