Code Duplication    Length = 20-20 lines in 2 locations

eZ/Publish/Core/Persistence/Cache/LocationHandler.php 2 locations

@@ 24-43 (lines=20) @@
21
    /**
22
     * {@inheritdoc}
23
     */
24
    public function load($locationId, array $translations = null, bool $useAlwaysAvailable = true)
25
    {
26
        $translationsKey = $this->getCacheTranslationKey($translations, $useAlwaysAvailable);
27
        $cacheItem = $this->cache->getItem("ez-location-${locationId}-${translationsKey}");
28
        if ($cacheItem->isHit()) {
29
            return $cacheItem->get();
30
        }
31
32
        $this->logger->logCall(
33
            __METHOD__,
34
            ['location' => $locationId, 'translations' => $translations, 'always-available' => $useAlwaysAvailable]
35
        );
36
        $location = $this->persistenceHandler->locationHandler()->load($locationId, $translations, $useAlwaysAvailable);
37
38
        $cacheItem->set($location);
39
        $cacheItem->tag($this->getCacheTags($location));
40
        $this->cache->save($cacheItem);
41
42
        return $location;
43
    }
44
45
    public function loadList(array $locationIds, array $translations = null, bool $useAlwaysAvailable = true): iterable
46
    {
@@ 147-166 (lines=20) @@
144
    /**
145
     * {@inheritdoc}
146
     */
147
    public function loadByRemoteId($remoteId, array $translations = null, bool $useAlwaysAvailable = true)
148
    {
149
        $translationsKey = $this->getCacheTranslationKey($translations, $useAlwaysAvailable);
150
        $cacheItem = $this->cache->getItem("ez-location-remoteid-${remoteId}-${translationsKey}");
151
        if ($cacheItem->isHit()) {
152
            return $cacheItem->get();
153
        }
154
155
        $this->logger->logCall(
156
            __METHOD__,
157
            ['location' => $remoteId, 'translations' => $translations, 'always-available' => $useAlwaysAvailable]
158
        );
159
        $location = $this->persistenceHandler->locationHandler()->loadByRemoteId($remoteId, $translations, $useAlwaysAvailable);
160
161
        $cacheItem->set($location);
162
        $cacheItem->tag($this->getCacheTags($location));
163
        $this->cache->save($cacheItem);
164
165
        return $location;
166
    }
167
168
    /**
169
     * {@inheritdoc}