Code Duplication    Length = 10-12 lines in 4 locations

Repositories/Cache/CacheNotificationDecorator.php 4 locations

@@ 21-30 (lines=10) @@
18
     * @param int $userId
19
     * @return \Illuminate\Database\Eloquent\Collection
20
     */
21
    public function latestForUser($userId)
22
    {
23
        return $this->cache
24
            ->tags([$this->entityName, 'global'])
25
            ->remember(
26
                "{$this->locale}.{$this->entityName}.latestForUser.{$userId}",
27
                $this->cacheTime,
28
                function () use ($userId) {
29
                    return $this->repository->latestForUser($userId);
30
                }
31
            );
32
    }
33
@@ 51-60 (lines=10) @@
48
     * @param int $userId
49
     * @return \Illuminate\Database\Eloquent\Collection
50
     */
51
    public function allForUser($userId)
52
    {
53
        return $this->cache
54
            ->tags([$this->entityName, 'global'])
55
            ->remember(
56
                "{$this->locale}.{$this->entityName}.allForUser.{$userId}",
57
                $this->cacheTime,
58
                function () use ($userId) {
59
                    return $this->repository->allForUser($userId);
60
                }
61
            );
62
    }
63
@@ 69-80 (lines=12) @@
66
     * @param int $userId
67
     * @return \Illuminate\Database\Eloquent\Collection
68
     */
69
    public function allReadForUser($userId)
70
    {
71
        return $this->cache
72
            ->tags([$this->entityName, 'global'])
73
            ->remember(
74
                "{$this->locale}.{$this->entityName}.allReadForUser.{$userId}",
75
                $this->cacheTime,
76
                function () use ($userId) {
77
                    return $this->repository->allReadForUser($userId);
78
                }
79
            );
80
    }
81
82
    /**
83
     * Get all the unread notifications for the given user id
@@ 87-96 (lines=10) @@
84
     * @param int $userId
85
     * @return \Illuminate\Database\Eloquent\Collection
86
     */
87
    public function allUnreadForUser($userId)
88
    {
89
        return $this->cache
90
            ->tags([$this->entityName, 'global'])
91
            ->remember(
92
                "{$this->locale}.{$this->entityName}.allUnreadForUser.{$userId}",
93
                $this->cacheTime,
94
                function () use ($userId) {
95
                    return $this->repository->allUnreadForUser($userId);
96
                }
97
            );
98
    }
99