Completed
Push — develop ( 9bc436...6029a0 )
by Jens
11:57
created

NullCacheAdapter::has()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 2
CRAP Score 1
Metric Value
dl 0
loc 4
ccs 2
cts 2
cp 1
rs 10
cc 1
eloc 2
nc 1
nop 2
crap 1
1
<?php
2
/**
3
 * @author @jayS-de <[email protected]>
4
 * @created 19.01.15, 17:06
5
 */
6
7
namespace Commercetools\Core\Cache;
8
9
/**
10
 * @package Commercetools\Core\Cache
11
 */
12
class NullCacheAdapter extends AbstractCacheAdapter
13
{
14
    protected $cache = [];
15
16
    /**
17
     * @param $key
18
     * @param $options
19
     * @return bool
20
     */
21 9
    public function has($key, $options = null)
22
    {
23 9
        return isset($this->cache[$key]);
24
    }
25
26
    /**
27
     * @param $key
28
     * @param $options
29
     * @return bool
30
     */
31 6
    public function fetch($key, $options = null)
32
    {
33 6
        if ($this->has($key)) {
34 5
            return $this->cache[$key];
35
        }
36 4
        return false;
37
    }
38
39
    /**
40
     * @param $key
41
     * @param $data
42
     * @param $lifeTime
43
     * @param $options
44
     * @return bool
45
     */
46 8
    public function store($key, $data, $lifeTime = null, $options = null)
47
    {
48 8
        $this->cache[$key] = $data;
49
50 8
        return true;
51
    }
52
53
    /**
54
     * @param $key
55
     * @param $options
56
     * @return bool
57
     */
58 2
    public function remove($key, $options = null)
59
    {
60 2
        unset($this->cache[$key]);
61 2
        return true;
62
    }
63
}
64