Code Duplication    Length = 19-19 lines in 3 locations

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

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