Code Duplication    Length = 19-19 lines in 3 locations

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

@@ 49-67 (lines=19) @@
46
    /**
47
     * {@inheritdoc}
48
     */
49
    public function load($locationId, array $translations = null, bool $useAlwaysAvailable = true)
50
    {
51
        $keySuffix = '-' . $this->getCacheTranslationKey($translations, $useAlwaysAvailable);
52
        $getLocationKeysFn = $this->getLocationKeys;
53
54
        return $this->getCacheValue(
55
            (int) $locationId,
56
            'ez-location-',
57
            function ($id) use ($translations, $useAlwaysAvailable) {
58
                return $this->persistenceHandler->locationHandler()->load($id, $translations, $useAlwaysAvailable);
59
            },
60
            $this->getLocationTags,
61
            static function (Location $location) use ($keySuffix, $getLocationKeysFn) {
62
                return $getLocationKeysFn($location, $keySuffix);
63
            },
64
            $keySuffix,
65
            ['location' => $locationId, 'translations' => $translations, 'alwaysAvailable' => $useAlwaysAvailable]
66
        );
67
    }
68
69
    public function loadList(array $locationIds, array $translations = null, bool $useAlwaysAvailable = true): iterable
70
    {
@@ 69-87 (lines=19) @@
66
        );
67
    }
68
69
    public function loadList(array $locationIds, array $translations = null, bool $useAlwaysAvailable = true): iterable
70
    {
71
        $keySuffix = '-' . $this->getCacheTranslationKey($translations, $useAlwaysAvailable);
72
        $getLocationKeysFn = $this->getLocationKeys;
73
74
        return $this->getMultipleCacheValues(
75
            $locationIds,
76
            'ez-location-',
77
            function (array $ids) use ($translations, $useAlwaysAvailable) {
78
                return $this->persistenceHandler->locationHandler()->loadList($ids, $translations, $useAlwaysAvailable);
79
            },
80
            $this->getLocationTags,
81
            static function (Location $location) use ($keySuffix, $getLocationKeysFn) {
82
                return $getLocationKeysFn($location, $keySuffix);
83
            },
84
            $keySuffix,
85
            ['location' => $locationIds, 'translations' => $translations, 'alwaysAvailable' => $useAlwaysAvailable]
86
        );
87
    }
88
89
    /**
90
     * {@inheritdoc}
@@ 187-205 (lines=19) @@
184
    /**
185
     * {@inheritdoc}
186
     */
187
    public function loadByRemoteId($remoteId, array $translations = null, bool $useAlwaysAvailable = true)
188
    {
189
        $keySuffix = '-' . $this->getCacheTranslationKey($translations, $useAlwaysAvailable);
190
        $getLocationKeysFn = $this->getLocationKeys;
191
192
        return $this->getCacheValue(
193
            $this->escapeForCacheKey($remoteId),
194
            'ez-location-remoteid-',
195
            function () use ($remoteId, $translations, $useAlwaysAvailable) {
196
                return $this->persistenceHandler->locationHandler()->loadByRemoteId($remoteId, $translations, $useAlwaysAvailable);
197
            },
198
            $this->getLocationTags,
199
            static function (Location $location) use ($keySuffix, $getLocationKeysFn) {
200
                return $getLocationKeysFn($location, $keySuffix);
201
            },
202
            $keySuffix,
203
            ['location' => $remoteId, 'translations' => $translations, 'alwaysAvailable' => $useAlwaysAvailable]
204
        );
205
    }
206
207
    /**
208
     * {@inheritdoc}