Total Complexity | 6 |
Total Lines | 47 |
Duplicated Lines | 0 % |
Coverage | 100% |
Changes | 0 |
1 | <?php declare(strict_types=1); |
||
8 | class BusinessIdentifierCodeFakerData extends AbstractFakerDataProvider |
||
9 | { |
||
10 | /** |
||
11 | * @see https://github.com/symfony/symfony/issues/18263 |
||
12 | * @see \Symfony\Component\Intl\Data\Generator\RegionDataGenerator |
||
13 | */ |
||
14 | public const EXCLUDED_CODES = [ |
||
15 | 'ZZ', |
||
16 | 'BV', |
||
17 | 'QO', |
||
18 | 'EU', |
||
19 | 'AN', |
||
20 | 'BV', |
||
21 | 'HM', |
||
22 | 'CP', |
||
23 | ]; |
||
24 | |||
25 | 4 | public function __construct(Generator $generator) |
|
26 | { |
||
27 | 4 | parent::__construct($generator); |
|
28 | 4 | } |
|
29 | |||
30 | |||
31 | 4 | public function __invoke(): string |
|
32 | { |
||
33 | 4 | return $this->getBank() . $this->getCountryCode() . $this->getRegionAndBranch(); |
|
34 | } |
||
35 | |||
36 | 4 | private function getBank(): string |
|
37 | { |
||
38 | 4 | return $this->generator->regexify('[A-Z]{4}'); |
|
39 | } |
||
40 | |||
41 | 4 | private function getCountryCode(): string |
|
42 | { |
||
43 | //to prevent issues when using as an archetype, otherwise this gets replaced with the new field property name |
||
44 | 4 | $property = 'country' . 'Code'; |
|
45 | do { |
||
46 | 4 | $code = $this->generator->$property; |
|
47 | 4 | } while (\in_array($code, self::EXCLUDED_CODES, true)); |
|
48 | |||
49 | 4 | return $code; |
|
50 | } |
||
51 | |||
52 | 4 | private function getRegionAndBranch(): string |
|
55 | } |
||
56 | } |
||
57 |