TestArrayCache::has()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 4

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 4
rs 10
c 0
b 0
f 0
cc 1
nc 1
nop 1
1
<?php
2
3
namespace DDesrosiers\Test\SilexAnnotations;
4
5
use Psr\SimpleCache\CacheInterface;
6
7
class TestArrayCache implements CacheInterface
8
{
9
    protected $fetchedIDs;
10
    private $cache;
11
12
    public function wasFetched($id)
13
    {
14
        return isset($this->fetchedIDs[$id]);
15
    }
16
17
    public function get($id, $default = null)
18
    {
19
        $this->fetchedIDs[$id] = true;
20
        return $this->cache[$id] ?? $default;
21
    }
22
23
    public function clearWasFetched()
24
    {
25
        $this->fetchedIDs = [];
26
    }
27
28
    public function set($key, $value, $ttl = null)
29
    {
30
        $this->cache[$key] = $value;
31
    }
32
33
    public function delete($key)
34
    {
35
        unset($this->cache[$key]);
36
    }
37
38
    public function clear()
39
    {
40
        $this->cache = [];
41
    }
42
43
    public function getMultiple($keys, $default = null)
44
    {
45
        // TODO: Implement getMultiple() method.
46
    }
47
48
    public function setMultiple($values, $ttl = null)
49
    {
50
        // TODO: Implement setMultiple() method.
51
    }
52
53
    public function deleteMultiple($keys)
54
    {
55
        // TODO: Implement deleteMultiple() method.
56
    }
57
58
    public function has($key)
59
    {
60
        return isset($this->cache[$key]);
61
    }
62
}
63