From 235d6a98906f14df6042b4b645f9920c31a78471 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 | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/src/Validator.php b/src/Validator.php index bac22e5..cb7eadd 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; @@ -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;