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