Total Complexity | 6 |
Total Lines | 38 |
Duplicated Lines | 0 % |
Coverage | 60% |
Changes | 0 |
1 | <?php declare(strict_types=1); |
||
9 | class LocaleIdentifierFakerData extends AbstractFakerDataProvider |
||
10 | { |
||
11 | |||
12 | /** |
||
13 | * @var string[] |
||
14 | */ |
||
15 | private static $locales; |
||
16 | |||
17 | /** |
||
18 | * LocaleIdentifierFakerDataProvider constructor. |
||
19 | * |
||
20 | * @param Generator $generator |
||
21 | * @SuppressWarnings(PHPMD.StaticAccess) |
||
22 | */ |
||
23 | 2 | public function __construct(Generator $generator) |
|
24 | { |
||
25 | 2 | parent::__construct($generator); |
|
26 | 2 | if (null === self::$locales) { |
|
|
|||
27 | 1 | self::$locales = Intl::getLocaleBundle()->getLocaleNames(); |
|
28 | } |
||
29 | 2 | } |
|
30 | |||
31 | 2 | public function __invoke(): string |
|
32 | { |
||
33 | do { |
||
34 | 2 | $value = $this->generator->locale; |
|
35 | 2 | } while (false === $this->isValid($value)); |
|
36 | |||
37 | 2 | return $value; |
|
38 | } |
||
39 | |||
40 | 2 | private function isValid(string $value): bool |
|
47 | } |
||
48 | } |
||
49 |