CacheMenuDecorator   A
last analyzed

Complexity

Total Complexity 2

Size/Duplication

Total Lines 29
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 2

Importance

Changes 1
Bugs 0 Features 1
Metric Value
wmc 2
c 1
b 0
f 1
lcom 1
cbo 2
dl 0
loc 29
rs 10

2 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 6 1
A allOnline() 0 10 1
1
<?php namespace Modules\Menu\Repositories\Cache;
2
3
use Modules\Core\Repositories\Cache\BaseCacheDecorator;
4
use Modules\Menu\Repositories\MenuRepository;
5
6
class CacheMenuDecorator extends BaseCacheDecorator implements MenuRepository
7
{
8
    /**
9
     * @var MenuRepository
10
     */
11
    protected $repository;
12
13
    public function __construct(MenuRepository $menu)
14
    {
15
        parent::__construct();
16
        $this->entityName = 'menus';
17
        $this->repository = $menu;
18
    }
19
20
    /**
21
     * Get all online menus
22
     * @return object
23
     */
24
    public function allOnline()
25
    {
26
        return $this->cache
27
            ->tags($this->entityName, 'global')
28
            ->remember("{$this->locale}.{$this->entityName}.allOnline", $this->cacheTime,
29
                function () {
30
                    return $this->repository->allOnline();
31
                }
32
            );
33
    }
34
}
35