Total Complexity | 5 |
Total Lines | 33 |
Duplicated Lines | 0 % |
Coverage | 100% |
Changes | 0 |
1 | <?php |
||
10 | class Registry implements RegistryInterface |
||
11 | { |
||
12 | /** |
||
13 | * @var Generator[] |
||
14 | */ |
||
15 | protected $generators = []; |
||
16 | |||
17 | 53 | public function getGeneratorForField(FieldMetadata $fieldMetadata) |
|
18 | { |
||
19 | 53 | return $this->getGeneratorForLocale($fieldMetadata->configuration->locale); |
|
20 | } |
||
21 | |||
22 | 73 | public function getGeneratorForLocale(?string $locale = null): Generator |
|
23 | { |
||
24 | 73 | $locale = $locale ?? Factory::DEFAULT_LOCALE; |
|
25 | |||
26 | 73 | if (empty($this->generators[$locale])) { |
|
27 | 73 | $this->generators[$locale] = $this->instantiate($locale); |
|
28 | } |
||
29 | |||
30 | 73 | return $this->generators[$locale]; |
|
31 | } |
||
32 | |||
33 | 27 | public function getGuesserForLocale(?string $locale = null): Name |
|
34 | { |
||
35 | 27 | $generator = $this->getGeneratorForLocale($locale); |
|
36 | |||
37 | 27 | return new Name($generator); |
|
38 | } |
||
39 | |||
40 | 73 | protected function instantiate($locale = null) |
|
43 | } |
||
44 | } |
||
45 |