Issues (138)

src/Traits/HasCacheTrait.php (1 issue)

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