VatNumberValidatorProvider   A
last analyzed

Complexity

Total Complexity 4

Size/Duplication

Total Lines 20
Duplicated Lines 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
eloc 7
dl 0
loc 20
rs 10
c 1
b 0
f 0
wmc 4

2 Methods

Rating   Name   Duplication   Size   Complexity  
A getValidator() 0 10 3
A __construct() 0 3 1
1
<?php
2
3
declare(strict_types=1);
4
5
namespace Gewebe\SyliusVATPlugin\Vat\Number;
6
7
class VatNumberValidatorProvider implements VatNumberValidatorProviderInterface
8
{
9
    /** @var VatNumberValidatorInterface[]|iterable */
10
    private iterable $validators;
11
12
    public function __construct(iterable $validators)
13
    {
14
        $this->validators = $validators;
15
    }
16
17
    public function getValidator(string $countryCode): ?VatNumberValidatorInterface
18
    {
19
        /** @var VatNumberValidatorInterface $validator */
20
        foreach ($this->validators as $validator) {
21
            if (in_array($countryCode, $validator->getCountries(), true)) {
22
                return $validator;
23
            }
24
        }
25
26
        return null;
27
    }
28
}
29