Total Complexity | 7 |
Total Lines | 49 |
Duplicated Lines | 0 % |
Changes | 1 | ||
Bugs | 0 | Features | 0 |
1 | <?php |
||
9 | class LocaleCollection |
||
10 | { |
||
11 | /** |
||
12 | * @var array<LocaleValueObject> |
||
13 | */ |
||
14 | protected array $locales = []; |
||
15 | |||
16 | public function add(LocaleValueObject $locale): void |
||
17 | { |
||
18 | $this->locales[] = $locale; |
||
19 | } |
||
20 | |||
21 | /** |
||
22 | * @return array<LocaleValueObject> |
||
23 | */ |
||
24 | public function toArray(): array |
||
25 | { |
||
26 | return $this->locales; |
||
27 | } |
||
28 | |||
29 | public function isEmpty(): bool |
||
30 | { |
||
31 | return $this->locales === []; |
||
32 | } |
||
33 | |||
34 | /** |
||
35 | * @param array<string> $locales |
||
36 | */ |
||
37 | public static function fromArray(array $locales): self |
||
38 | { |
||
39 | $collection = new self(); |
||
40 | foreach ($locales as $item) { |
||
41 | $collection->add(new LocaleValueObject($item)); |
||
42 | } |
||
43 | |||
44 | return $collection; |
||
45 | } |
||
46 | |||
47 | /** |
||
48 | * @param array<LocaleValueObject> $locales |
||
49 | */ |
||
50 | public static function fromArrayLocales(array $locales): self |
||
58 | } |
||
59 | } |
||
60 |