| Total Complexity | 9 |
| Total Lines | 43 |
| Duplicated Lines | 0 % |
| Changes | 0 | ||
| 1 | <?php |
||
| 16 | final class EuVatNumberValidator implements VatNumberValidatorInterface |
||
| 17 | { |
||
| 18 | public function __construct(private Validator $validator) |
||
| 19 | { |
||
| 20 | } |
||
| 21 | |||
| 22 | public function getCountries(): array |
||
| 23 | { |
||
| 24 | $countries = new Countries(); |
||
| 25 | $euCountries = []; |
||
| 26 | |||
| 27 | /** @var string $countryCode */ |
||
| 28 | foreach (array_keys(iterator_to_array($countries)) as $countryCode) { |
||
| 29 | if ($countries->isCountryCodeInEU($countryCode)) { |
||
| 30 | $euCountries[] = $countryCode; |
||
| 31 | } |
||
| 32 | } |
||
| 33 | |||
| 34 | return $euCountries; |
||
| 35 | } |
||
| 36 | |||
| 37 | public function validateCountry(string $vatNumber, string $countryCode): bool |
||
| 38 | { |
||
| 39 | $country = substr($vatNumber, 0, 2); |
||
| 40 | |||
| 41 | if (strtolower($country) === strtolower($countryCode)) { |
||
| 42 | return true; |
||
| 43 | } |
||
| 44 | |||
| 45 | return false; |
||
| 46 | } |
||
| 47 | |||
| 48 | public function validateFormat(string $vatNumber): bool |
||
| 51 | } |
||
| 52 | |||
| 53 | public function validate(string $vatNumber): bool |
||
| 59 | } |
||
| 60 | } |
||
| 62 |