Total Complexity | 8 |
Total Lines | 41 |
Duplicated Lines | 0 % |
Changes | 0 |
1 | <?php |
||
15 | trait InteractsWithCache |
||
16 | { |
||
17 | /** |
||
18 | * @var CacheInterface |
||
19 | */ |
||
20 | protected $cache; |
||
21 | |||
22 | /** |
||
23 | * @return CacheInterface|FilesystemCache |
||
24 | */ |
||
25 | public function getCache() |
||
26 | { |
||
27 | if ($this->cache) { |
||
28 | return $this->cache; |
||
29 | } |
||
30 | |||
31 | if (property_exists($this, 'app') && $this->app instanceof ServiceContainer |
||
32 | && isset($this->app['cache']) && $this->app['cache'] instanceof CacheInterface) { |
||
33 | return $this->cache = $this->app['cache']; |
||
34 | } |
||
35 | |||
36 | return $this->cache = $this->createDefaultCache(); |
||
37 | } |
||
38 | |||
39 | /** |
||
40 | * @param CacheInterface $cache |
||
41 | * @return $this |
||
42 | */ |
||
43 | public function setCache(CacheInterface $cache) |
||
48 | } |
||
49 | |||
50 | /** |
||
51 | * @return FilesystemCache |
||
52 | */ |
||
53 | protected function createDefaultCache() |
||
56 | } |
||
57 | } |
||
58 |