Passed
Push — master ( 159f4a...679316 )
by
unknown
02:11
created

NullCache::getMultiple()   A

Complexity

Conditions 2
Paths 2

Size

Total Lines 7
Code Lines 4

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 5
CRAP Score 2

Importance

Changes 0
Metric Value
eloc 4
c 0
b 0
f 0
dl 0
loc 7
ccs 5
cts 5
cp 1
rs 10
cc 2
nc 2
nop 2
crap 2
1
<?php
2
3
namespace Vectorface\Cache;
4
5
/**
6
 * A cache that caches nothing and always fails.
7
 */
8
class NullCache implements Cache
9
{
10
    /**
11
     * @inheritDoc
12
     */
13 3
    public function get($key, $default = null)
14
    {
15 3
        return $default;
16
    }
17
18
    /**
19
     * @inheritDoc
20
     */
21 4
    public function set($key, $value, $ttl = null)
22
    {
23 4
        return false;
24
    }
25
26
    /**
27
     * @inheritDoc
28
     */
29 3
    public function delete($key)
30
    {
31 3
        return false;
32
    }
33
34
    /**
35
     * @inheritDoc
36
     */
37 3
    public function clean()
38
    {
39 3
        return false;
40
    }
41
42
    /**
43
     * @inheritDoc
44
     */
45 3
    public function flush()
46
    {
47 3
        return false;
48
    }
49
50
    /**
51
     * @inheritDoc
52
     */
53 1
    public function clear()
54
    {
55 1
        return false;
56
    }
57
58
    /**
59
     * @inheritDoc
60
     */
61 2
    public function getMultiple($keys, $default = null)
62
    {
63 2
        $defaults = [];
64 2
        foreach ($keys as $key) {
65 2
            $defaults[$key] = $default;
66
        }
67 2
        return $defaults;
68
    }
69
70
    /**
71
     * @inheritDoc
72
     */
73 2
    public function setMultiple($values, $ttl = null)
74
    {
75 2
        return false;
0 ignored issues
show
Bug Best Practice introduced by
The expression return false returns the type false which is incompatible with the return type mandated by Vectorface\Cache\Cache::setMultiple() of Traversable|array.

In the issue above, the returned value is violating the contract defined by the mentioned interface.

Let's take a look at an example:

interface HasName {
    /** @return string */
    public function getName();
}

class Name {
    public $name;
}

class User implements HasName {
    /** @return string|Name */
    public function getName() {
        return new Name('foo'); // This is a violation of the ``HasName`` interface
                                // which only allows a string value to be returned.
    }
}
Loading history...
76
    }
77
78
    /**
79
     * @inheritDoc
80
     */
81 2
    public function deleteMultiple($keys)
82
    {
83 2
        return false;
84
    }
85
86
    /**
87
     * @inheritDoc
88
     */
89 1
    public function has($key)
90
    {
91 1
        return false;
92
    }
93
}
94