CacheManager   A
last analyzed

Complexity

Total Complexity 6

Size/Duplication

Total Lines 63
Duplicated Lines 0 %

Test Coverage

Coverage 0%

Importance

Changes 1
Bugs 0 Features 0
Metric Value
eloc 11
c 1
b 0
f 0
dl 0
loc 63
ccs 0
cts 16
cp 0
rs 10
wmc 6

6 Methods

Rating   Name   Duplication   Size   Complexity  
A filePath() 0 5 1
A setManager() 0 5 1
A getCacheId() 0 5 1
A cachePath() 0 3 1
A getManager() 0 3 1
A __construct() 0 3 1
1
<?php
2
3
namespace Nip\Records;
4
5
use Nip\Records\AbstractModels\RecordManager as Records;
6
7
/**
8
 * Class CacheManager
9
 * @package Nip\Records
10
 */
11
class CacheManager extends \Nip\Cache\Manager
12
{
13
14
    /**
15
     * @var Records
16
     */
17
    protected $_manager;
18
19
    /**
20
     * CacheManager constructor.
21
     */
22
    public function __construct()
23
    {
24
        $this->active = (request()->getModuleName() == 'default');
25
    }
26
27
    /**
28
     * @param $cacheId
29
     * @return string
30
     */
31
    public function filePath($cacheId)
32
    {
33
        $cacheId = $this->getCacheId($cacheId);
34
35
        return $this->cachePath() . $cacheId . '.php';
36
    }
37
38
    /**
39
     * @param bool $type
40
     * @return string
41
     */
42
    public function getCacheId($type = false)
43
    {
44
        $cacheId = $this->getManager()->getController() . '-' . $type;
45
46
        return $cacheId;
47
    }
48
49
    /**
50
     * @return Records
51
     */
52
    public function getManager()
53
    {
54
        return $this->_manager;
55
    }
56
57
    /**
58
     * @param Records $manager
59
     * @return $this
60
     */
61
    public function setManager($manager)
62
    {
63
        $this->_manager = $manager;
64
65
        return $this;
66
    }
67
68
    /**
69
     * @return string
70
     */
71
    public function cachePath()
72
    {
73
        return parent::cachePath() . '/records/';
74
    }
75
}
76