CacheAwareTrait   A
last analyzed

Complexity

Total Complexity 3

Size/Duplication

Total Lines 33
Duplicated Lines 0 %

Test Coverage

Coverage 100%

Importance

Changes 1
Bugs 0 Features 0
Metric Value
wmc 3
eloc 7
c 1
b 0
f 0
dl 0
loc 33
ccs 8
cts 8
cp 1
rs 10

3 Methods

Rating   Name   Duplication   Size   Complexity  
A setCacheKey() 0 3 1
A setCacheTTL() 0 3 1
A setCache() 0 3 1
1
<?php declare(strict_types=1);
2
3
namespace Phact\Router;
4
5
use DateInterval;
6
use Psr\SimpleCache\CacheInterface;
7
8
trait CacheAwareTrait
9
{
10
    /** @var CacheInterface */
11
    protected $cache;
12
13
    /** @var string */
14
    protected $cacheKey = 'routes';
15
16
    /** @var null|int|DateInterval */
17
    protected $cacheTTL;
18
19
    /**
20
     * @inheritDoc
21
     */
22 4
    public function setCache(CacheInterface $cache): void
23
    {
24 4
        $this->cache = $cache;
25 4
    }
26
27
    /**
28
     * @inheritDoc
29
     */
30 1
    public function setCacheKey(string $key = 'routes'): void
31
    {
32 1
        $this->cacheKey = $key;
33 1
    }
34
35
    /**
36
     * @inheritDoc
37
     */
38 1
    public function setCacheTTL($ttl = 60): void
39
    {
40 1
        $this->cacheTTL = $ttl;
41 1
    }
42
}
43