Code Duplication    Length = 10-12 lines in 4 locations

Repositories/Cache/CachePostDecorator.php 3 locations

@@ 21-30 (lines=10) @@
18
     * @param int $amount
19
     * @return Collection
20
     */
21
    public function latest($amount = 5)
22
    {
23
        return $this->cache
24
            ->tags($this->entityName, 'global')
25
            ->remember("{$this->locale}.{$this->entityName}.latest.{$amount}", $this->cacheTime,
26
                function () use ($amount) {
27
                    return $this->repository->latest($amount);
28
                }
29
            );
30
    }
31
32
    /**
33
     * Get the previous post of the given post
@@ 37-48 (lines=12) @@
34
     * @param object $post
35
     * @return object
36
     */
37
    public function getPreviousOf($post)
38
    {
39
        $postId = $post->id;
40
41
        return $this->cache
42
            ->tags($this->entityName, 'global')
43
            ->remember("{$this->locale}.{$this->entityName}.getPreviousOf.{$postId}", $this->cacheTime,
44
                function () use ($post) {
45
                    return $this->repository->getPreviousOf($post);
46
                }
47
            );
48
    }
49
50
    /**
51
     * Get the next post of the given post
@@ 55-66 (lines=12) @@
52
     * @param object $post
53
     * @return object
54
     */
55
    public function getNextOf($post)
56
    {
57
        $postId = $post->id;
58
59
        return $this->cache
60
            ->tags($this->entityName, 'global')
61
            ->remember("{$this->locale}.{$this->entityName}.getNextOf.{$postId}", $this->cacheTime,
62
                function () use ($post) {
63
                    return $this->repository->getNextOf($post);
64
                }
65
            );
66
    }
67
}
68

Repositories/Cache/CacheTagDecorator.php 1 location

@@ 24-33 (lines=10) @@
21
     * @param $name
22
     * @return mixed
23
     */
24
    public function findByName($name)
25
    {
26
        return $this->cache
27
            ->tags($this->entityName, 'global')
28
            ->remember("{$this->locale}.{$this->entityName}.findByName.{$name}", $this->cacheTime,
29
                function () use ($name) {
30
                    return $this->repository->findByName($name);
31
                }
32
            );
33
    }
34
35
    /**
36
     * Create the tag for the specified language