Conditions | 4 |
Paths | 4 |
Total Lines | 17 |
Code Lines | 9 |
Lines | 0 |
Ratio | 0 % |
Changes | 1 | ||
Bugs | 1 | Features | 0 |
1 | <?php |
||
21 | public function __construct(array $locales, string $defaultLocale, array $requiredLocales = []) |
||
22 | { |
||
23 | if (empty($locales)) { |
||
24 | throw new \InvalidArgumentException('No locales were configured, but expected at least one locale. Check `i18n_form.locales` bundle configuration!'); |
||
25 | } |
||
26 | |||
27 | if (!\in_array($defaultLocale, $locales, true)) { |
||
28 | throw new \InvalidArgumentException(sprintf('Default locale `%s` not found within the configured locales `[%s]`. Perhaps you need to add it to your `i18n_form.locales` bundle configuration?', $defaultLocale, implode(',', $locales))); |
||
29 | } |
||
30 | |||
31 | if (array_diff($requiredLocales, $locales)) { |
||
32 | throw new \InvalidArgumentException('Required locales should be contained in locales'); |
||
33 | } |
||
34 | |||
35 | $this->locales = $locales; |
||
36 | $this->defaultLocale = $defaultLocale; |
||
37 | $this->requiredLocales = $requiredLocales; |
||
38 | } |
||
64 |