Completed
Pull Request — master (#25)
by
unknown
02:43
created

CachePageDecorator::findHomepage()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 10
Code Lines 6

Duplication

Lines 10
Ratio 100 %

Importance

Changes 0
Metric Value
c 0
b 0
f 0
dl 10
loc 10
rs 9.4285
cc 1
eloc 6
nc 1
nop 0
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')
0 ignored issues
show
Unused Code introduced by
The call to Repository::tags() has too many arguments starting with 'global'.

This check compares calls to functions or methods with their respective definitions. If the call has more arguments than are defined, it raises an issue.

If a function is defined several times with a different number of parameters, the check may pick up the wrong definition and report false positives. One codebase where this has been known to happen is Wordpress.

In this case you can add the @ignore PhpDoc annotation to the duplicate definition and it will be ignored.

Loading history...
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')
0 ignored issues
show
Unused Code introduced by
The call to Repository::tags() has too many arguments starting with 'global'.

This check compares calls to functions or methods with their respective definitions. If the call has more arguments than are defined, it raises an issue.

If a function is defined several times with a different number of parameters, the check may pick up the wrong definition and report false positives. One codebase where this has been known to happen is Wordpress.

In this case you can add the @ignore PhpDoc annotation to the duplicate definition and it will be ignored.

Loading history...
44
            ->remember("{$this->locale}.{$this->entityName}.countAll", $this->cacheTime,
45
                function () {
46
                    return $this->repository->countAll();
47
                }
48
            );
49
    }
50
51
    /**
52
     * @param $slug
53
     * @param $locale
54
     * @return object
55
     */
56
    public function findBySlugInLocale($slug, $locale)
57
    {
58
        return $this->cache
59
            ->tags($this->entityName, 'global')
0 ignored issues
show
Unused Code introduced by
The call to Repository::tags() has too many arguments starting with 'global'.

This check compares calls to functions or methods with their respective definitions. If the call has more arguments than are defined, it raises an issue.

If a function is defined several times with a different number of parameters, the check may pick up the wrong definition and report false positives. One codebase where this has been known to happen is Wordpress.

In this case you can add the @ignore PhpDoc annotation to the duplicate definition and it will be ignored.

Loading history...
60
            ->remember("{$this->locale}.{$this->entityName}.findBySlugInLocale.{$slug}.{$locale}", $this->cacheTime,
61
                function () use ($slug, $locale) {
62
                    return $this->repository->findBySlugInLocale($slug, $locale);
63
                }
64
            );
65
    }
66
}
67