CacheTagDecorator   A
last analyzed

Complexity

Total Complexity 2

Size/Duplication

Total Lines 25
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 3

Importance

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

2 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 6 1
A allForNamespace() 0 10 1
1
<?php
2
3
namespace Modules\Tag\Repositories\Cache;
4
5
use Modules\Core\Repositories\Cache\BaseCacheDecorator;
6
use Modules\Tag\Repositories\TagRepository;
7
8
class CacheTagDecorator extends BaseCacheDecorator implements TagRepository
9
{
10
    public function __construct(TagRepository $tag)
11
    {
12
        parent::__construct();
13
        $this->entityName = 'tag.tags';
14
        $this->repository = $tag;
15
    }
16
17
    /**
18
     * Get all the tags in the given namespace
19
     * @param string $namespace
20
     * @return \Illuminate\Database\Eloquent\Collection
21
     */
22
    public function allForNamespace($namespace)
23
    {
24
        return $this->cache
25
            ->tags([$this->entityName, 'global'])
26
            ->remember("{$this->locale}.{$this->entityName}.allForNamespace.{$namespace}", $this->cacheTime,
27
                function () use ($namespace) {
28
                    return $this->repository->allForNamespace($namespace);
29
                }
30
            );
31
    }
32
}
33