WidgetCacheRepository::getPublished()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 6
Code Lines 3

Duplication

Lines 6
Ratio 100 %

Importance

Changes 0
Metric Value
cc 1
eloc 3
nc 1
nop 0
dl 6
loc 6
rs 9.4285
c 0
b 0
f 0
1
<?php
2
3
namespace Yajra\CMS\Repositories\Widget;
4
5
use Illuminate\Contracts\Cache\Repository as Cache;
6
7 View Code Duplication
class WidgetCacheRepository implements WidgetRepository
0 ignored issues
show
Duplication introduced by
This class 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...
8
{
9
    /**
10
     * @var \Yajra\CMS\Repositories\Widget\WidgetRepository
11
     */
12
    protected $repository;
13
14
    /**
15
     * @var \Illuminate\Contracts\Cache\Repository
16
     */
17
    protected $cache;
18
19
    /**
20
     * WidgetCacheRepository constructor.
21
     *
22
     * @param \Yajra\CMS\Repositories\Widget\WidgetRepository $repository
23
     * @param \Illuminate\Contracts\Cache\Repository $cache
24
     */
25
    public function __construct(WidgetRepository $repository, Cache $cache)
26
    {
27
        $this->repository = $repository;
28
        $this->cache      = $cache;
29
    }
30
31
    /**
32
     * Get all widgets.
33
     *
34
     * @return \Illuminate\Database\Eloquent\Collection|static[]
35
     */
36
    public function all()
37
    {
38
        return $this->cache->rememberForever('widgets.all', function () {
39
            return $this->repository->all();
40
        });
41
    }
42
43
    /**
44
     * Get all published widgets.
45
     *
46
     * @return \Illuminate\Database\Eloquent\Collection|static[]
47
     */
48
    public function getPublished()
49
    {
50
        return $this->cache->rememberForever('widgets.published', function () {
51
            return $this->repository->getPublished();
52
        });
53
    }
54
}