HasCacheTrait   A
last analyzed

Complexity

Total Complexity 4

Size/Duplication

Total Lines 33
Duplicated Lines 0 %

Test Coverage

Coverage 77.78%

Importance

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

3 Methods

Rating   Name   Duplication   Size   Complexity  
A isCache() 0 3 1
A getCache() 0 6 2
A setCache() 0 3 1
1
<?php
2
3
namespace Nip\Form\Traits;
4
5
/**
6
 * Trait HasCacheTrait
7
 * @package Nip\Form\Traits
8
 */
9
trait HasCacheTrait
10
{
11
    protected $_cache;
12
13
    /**
14
     * @param $key
15
     * @param null $default
0 ignored issues
show
Documentation Bug introduced by
Are you sure the doc-type for parameter $default is correct as it would always require null to be passed?
Loading history...
16
     * @return mixed
17
     */
18 11
    public function getCache($key, $default = null)
19
    {
20 11
        if (!isset($this->_cache[$key])) {
21 11
            return $default;
22
        }
23 6
        return $this->_cache[$key];
24
    }
25
26
    /**
27
     * @param string $key
28
     * @param $value
29
     */
30 11
    public function setCache($key, $value)
31
    {
32 11
        $this->_cache[$key] = $value;
33 11
    }
34
35
    /**
36
     * @param $key
37
     * @return bool
38
     */
39
    public function isCache($key)
40
    {
41
        return isset($this->_cache[$key]);
42
    }
43
}
44