CachePageDecorator::__construct()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 6
Code Lines 4

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 1
Metric Value
c 1
b 0
f 1
dl 0
loc 6
rs 9.4286
cc 1
eloc 4
nc 1
nop 1
1
<?php namespace Modules\Page\Repositories\Cache;
2
3
use Modules\Core\Repositories\Cache\BaseCacheDecorator;
4
use Modules\Page\Repositories\PageRepository;
5
6
class CachePageDecorator extends BaseCacheDecorator implements PageRepository
7
{
8
    /**
9
     * @var PageRepository
10
     */
11
    protected $repository;
12
13
    public function __construct(PageRepository $page)
14
    {
15
        parent::__construct();
16
        $this->entityName = 'pages';
17
        $this->repository = $page;
18
    }
19
20
    /**
21
     * Find the page set as homepage
22
     *
23
     * @return object
24
     */
25 View Code Duplication
    public function findHomepage()
0 ignored issues
show
Duplication introduced by
This method seems to be duplicated in your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
26
    {
27
        return $this->cache
28
            ->tags($this->entityName, 'global')
29
            ->remember("{$this->locale}.{$this->entityName}.findHomepage", $this->cacheTime,
30
                function () {
31
                    return $this->repository->findHomepage();
32
                }
33
            );
34
    }
35
36
    /**
37
     * Count all records
38
     * @return int
39
     */
40 View Code Duplication
    public function countAll()
0 ignored issues
show
Duplication introduced by
This method seems to be duplicated in your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
41
    {
42
        return $this->cache
43
            ->tags($this->entityName, 'global')
44
            ->remember("{$this->locale}.{$this->entityName}.countAll", $this->cacheTime,
45
                function () {
46
                    return $this->repository->countAll();
47
                }
48
            );
49
    }
50
}
51