Code Duplication    Length = 20-21 lines in 4 locations

eZ/Publish/Core/Persistence/Legacy/Content/Language/CachingHandler.php 2 locations

@@ 96-116 (lines=21) @@
93
    /**
94
     * {@inheritdoc}
95
     */
96
    public function loadList(array $ids): iterable
97
    {
98
        $missing = [];
99
        $languages = [];
100
        foreach ($ids as $id) {
101
            if ($language = $this->cache->get('ez-language-' . $id)) {
102
                $languages[$id] = $language;
103
            } else {
104
                $missing[] = $id;
105
            }
106
        }
107
108
        if (!empty($missing)) {
109
            $loaded = $this->innerHandler->loadList($missing);
110
            $this->storeCache($loaded);
111
            /** @noinspection AdditionOperationOnArraysInspection */
112
            $languages += $loaded;
113
        }
114
115
        return $languages;
116
    }
117
118
    /**
119
     * Get language by Language Code (eg: eng-GB).
@@ 141-161 (lines=21) @@
138
    /**
139
     * {@inheritdoc}
140
     */
141
    public function loadListByLanguageCodes(array $languageCodes): iterable
142
    {
143
        $missing = [];
144
        $languages = [];
145
        foreach ($languageCodes as $languageCode) {
146
            if ($language = $this->cache->get('ez-language-code-' . $languageCode)) {
147
                $languages[$languageCode] = $language;
148
            } else {
149
                $missing[] = $languageCode;
150
            }
151
        }
152
153
        if (!empty($missing)) {
154
            $loaded = $this->innerHandler->loadListByLanguageCodes($missing);
155
            $this->storeCache($loaded);
156
            /** @noinspection AdditionOperationOnArraysInspection */
157
            $languages += $loaded;
158
        }
159
160
        return $languages;
161
    }
162
163
    /**
164
     * Get all languages.

eZ/Publish/Core/Persistence/Legacy/Content/Type/MemoryCachingHandler.php 2 locations

@@ 100-119 (lines=20) @@
97
    /**
98
     * {@inheritdoc}
99
     */
100
    public function loadGroups(array $groupIds)
101
    {
102
        $groups = $missingIds = [];
103
        foreach ($groupIds as $groupId) {
104
            if ($group = $this->cache->get('ez-content-type-group-' . $groupId)) {
105
                $groups[$groupId] = $group;
106
            } else {
107
                $missingIds[] = $groupId;
108
            }
109
        }
110
111
        if (!empty($missingIds)) {
112
            $loaded = $this->innerHandler->loadGroups($missingIds);
113
            $this->storeGroupCache($loaded);
114
            /** @noinspection AdditionOperationOnArraysInspection */
115
            $groups += $loaded;
116
        }
117
118
        return $groups;
119
    }
120
121
    /**
122
     * {@inheritdoc}
@@ 170-189 (lines=20) @@
167
    /**
168
     * {@inheritdoc}
169
     */
170
    public function loadContentTypeList(array $contentTypeIds): array
171
    {
172
        $contentTypes = $missingIds = [];
173
        foreach ($contentTypeIds as $contentTypeId) {
174
            if ($contentType = $this->cache->get('ez-content-type-' . $contentTypeId . '-' . Type::STATUS_DEFINED)) {
175
                $contentTypes[$contentTypeId] = $contentType;
176
            } else {
177
                $missingIds[] = $contentTypeId;
178
            }
179
        }
180
181
        if (!empty($missingIds)) {
182
            $loaded = $this->innerHandler->loadContentTypeList($missingIds);
183
            $this->storeTypeCache($loaded);
184
            /** @noinspection AdditionOperationOnArraysInspection */
185
            $contentTypes += $loaded;
186
        }
187
188
        return $contentTypes;
189
    }
190
191
    /**
192
     * {@inheritdoc}