Passed
Pull Request — master (#19)
by Christoffer
02:11
created

RuntimeCache::hasItem()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 3
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 1
eloc 1
nc 1
nop 1
dl 0
loc 3
rs 10
c 0
b 0
f 0
1
<?php
2
3
namespace Digia\GraphQL\Cache;
4
5
class RuntimeCache implements CacheInterface
6
{
7
8
    /**
9
     * @var array
10
     */
11
    private $_cache = [];
12
13
    /**
14
     * @inheritdoc
15
     */
16
    public function getItem(string $key)
17
    {
18
        return $this->_cache[$key] ?? null;
19
    }
20
21
    /**
22
     * @inheritdoc
23
     */
24
    public function hasItem(string $key): bool
25
    {
26
        return isset($this->_cache[$key]);
27
    }
28
29
    /**
30
     * @param string $key
31
     * @return bool
32
     */
33
    public function deleteItem(string $key): bool
34
    {
35
        unset($this->_cache[$key]);
36
        return true;
37
    }
38
39
    /**
40
     * @param string $key
41
     * @param mixed  $value
42
     * @return bool
43
     */
44
    public function setItem(string $key, $value): bool
45
    {
46
        $this->_cache[$key] = $value;
47
        return true;
48
    }
49
50
    /**
51
     * @return bool
52
     */
53
    public function commit(): bool
54
    {
55
        return true;
56
    }
57
}
58