Passed
Pull Request — master (#31)
by Alexander
01:41
created

NullCache::deleteMultiple()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 3
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 2
CRAP Score 1

Importance

Changes 0
Metric Value
eloc 1
c 0
b 0
f 0
dl 0
loc 3
ccs 2
cts 2
cp 1
rs 10
cc 1
nc 1
nop 1
crap 1
1
<?php declare(strict_types=1);
2
3
namespace Yiisoft\Cache;
4
5
use Yiisoft\Cache\Dependency\Dependency;
6
7
/**
8
 * NullCache does not cache anything reporting success for all methods calls.
9
 *
10
 * By replacing it with some other cache component, one can quickly switch from
11
 * non-caching mode to caching mode.
12
 */
13
final class NullCache implements CacheInterface
14
{
15 1
    public function add($key, $value, $ttl = 0, Dependency $dependency = null): bool
16
    {
17 1
        return true;
18
    }
19
20 1
    public function deleteMultiple($keys): bool
21
    {
22 1
        return true;
23
    }
24
25 1
    public function set($key, $value, $ttl = null, Dependency $dependency = null): bool
26
    {
27 1
        return true;
28
    }
29
30 1
    public function get($key, $default = null)
31
    {
32 1
        return $default;
33
    }
34
35 1
    public function getMultiple($keys, $default = null): iterable
36
    {
37 1
        return array_fill_keys($this->iterableToArray($keys), $default);
38
    }
39
40 1
    public function setMultiple($values, $ttl = null, Dependency $dependency = null): bool
41
    {
42 1
        return true;
43
    }
44
45 1
    public function addMultiple(array $values, $ttl = null, Dependency $dependency = null): bool
46
    {
47 1
        return true;
48
    }
49
50 1
    public function getOrSet($key, callable $callable, $ttl = null, Dependency $dependency = null)
51
    {
52 1
        return $callable($this);
53
    }
54
55 1
    public function delete($key): bool
56
    {
57 1
        return true;
58
    }
59
60 1
    public function clear(): bool
61
    {
62 1
        return true;
63
    }
64
65 1
    public function has($key): bool
66
    {
67 1
        return false;
68
    }
69
70
    public function enableKeyNormalization(): void
71
    {
72
        // do nothing
73
    }
74
75
    public function disableKeyNormalization(): void
76
    {
77
        // do nothing
78
    }
79
80
    public function setKeyPrefix(string $keyPrefix): void
81
    {
82
        // do nothing
83
    }
84
85 1
    private function iterableToArray(iterable $iterable): array
86
    {
87 1
        return $iterable instanceof \Traversable ? iterator_to_array($iterable) : (array)$iterable;
88
    }
89
}
90