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