Code Duplication    Length = 16-24 lines in 2 locations

eZ/Publish/Core/Persistence/Cache/ObjectStateHandler.php 1 location

@@ 254-269 (lines=16) @@
251
    /**
252
     * {@inheritdoc}
253
     */
254
    public function getContentState($contentId, $stateGroupId)
255
    {
256
        $cacheItem = $this->cache->getItem('ez-state-by-group-' . $stateGroupId . '-on-content-' . $contentId);
257
        if ($cacheItem->isHit()) {
258
            return $cacheItem->get();
259
        }
260
261
        $this->logger->logCall(__METHOD__, array('contentId' => $contentId, 'stateGroupId' => $stateGroupId));
262
        $contentState = $this->persistenceHandler->objectStateHandler()->getContentState($contentId, $stateGroupId);
263
264
        $cacheItem->set($contentState);
265
        $cacheItem->tag(['state-' . $contentState->id, 'content-' . $contentId]);
266
        $this->cache->save($cacheItem);
267
268
        return $contentState;
269
    }
270
271
    /**
272
     * {@inheritdoc}

eZ/Publish/Core/Persistence/Cache/UserPreferenceHandler.php 1 location

@@ 66-89 (lines=24) @@
63
    /**
64
     * {@inheritdoc}
65
     */
66
    public function getUserPreferenceByUserIdAndName(int $userId, string $name): UserPreference
67
    {
68
        $cacheItem = $this->cache->getItem('ez-user-preference-' . $userId . '-' . $name);
69
70
        $userPreference = $cacheItem->get();
71
        if ($cacheItem->isHit()) {
72
            return $userPreference;
73
        }
74
75
        $this->logger->logCall(__METHOD__, [
76
            'userId' => $userId,
77
            'name' => $name,
78
        ]);
79
80
        $userPreference = $this->persistenceHandler->userPreferenceHandler()->getUserPreferenceByUserIdAndName($userId, $name);
81
82
        $cacheItem->set($userPreference);
83
        $cacheItem->tag([
84
            'user-preference-' . $userId . '-' . $name,
85
        ]);
86
        $this->cache->save($cacheItem);
87
88
        return $userPreference;
89
    }
90
91
    /**
92
     * {@inheritdoc}