1 | <?php |
||
11 | class LanguageService |
||
12 | { |
||
13 | /** |
||
14 | * @var LanguageRepository |
||
15 | */ |
||
16 | private $languageRepository; |
||
17 | |||
18 | /** |
||
19 | * LanguageService constructor. |
||
20 | * |
||
21 | * @param LanguageRepository $languageRepository |
||
22 | */ |
||
23 | public function __construct(LanguageRepository $languageRepository) |
||
27 | |||
28 | /** |
||
29 | * Fetches all languages. |
||
30 | * |
||
31 | * @return LanguageEntity[] |
||
32 | */ |
||
33 | public function fetchAll() |
||
37 | |||
38 | /** |
||
39 | * Fetches all translated languages. |
||
40 | * |
||
41 | * @return LanguageEntity[] |
||
42 | */ |
||
43 | public function fetchAllTranslated() |
||
47 | |||
48 | /** |
||
49 | * Creates a language in the database. |
||
50 | * |
||
51 | * @param LanguageEntity $entity |
||
52 | * |
||
53 | * @return LanguageEntity |
||
54 | */ |
||
55 | public function create(LanguageEntity $entity) |
||
59 | |||
60 | /** |
||
61 | * Update a language in the database. |
||
62 | * |
||
63 | * @param LanguageEntity $entity |
||
64 | * |
||
65 | * @return LanguageEntity |
||
66 | */ |
||
67 | public function update(LanguageEntity $entity) |
||
71 | |||
72 | /** |
||
73 | * Removes a language from the database. |
||
74 | * |
||
75 | * @param LanguageEntity $entity |
||
76 | * |
||
77 | * @return LanguageEntity |
||
78 | */ |
||
79 | public function remove(LanguageEntity $entity) |
||
83 | |||
84 | /** |
||
85 | * Fetches all translated languages and aggregates them to an array of locales. |
||
86 | * |
||
87 | * @return string[] |
||
88 | */ |
||
89 | public function getAvailableTranslations() |
||
101 | } |
||
102 |
There are different options of fixing this problem.
If you want to be on the safe side, you can add an additional type-check:
If you are sure that the expression is traversable, you might want to add a doc comment cast to improve IDE auto-completion and static analysis:
Mark the issue as a false-positive: Just hover the remove button, in the top-right corner of this issue for more options.