Completed
Push — master ( e6a348...ceafb8 )
by Martin
12:34
created

NullCacheItemPool::deleteItem()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
c 1
b 0
f 0
dl 0
loc 4
rs 10
cc 1
eloc 2
nc 1
nop 1
1
<?php
2
namespace Psr6NullCache\Adapter;
3
4
use Psr\Cache\CacheItemPoolInterface;
5
use Psr\Cache\CacheItemInterface;
6
use Psr6NullCache\CacheItem;
7
8
final class NullCacheItemPool implements CacheItemPoolInterface
9
{
10
11
    /**
12
     * Returns a Cache Item representing the specified key.
13
     *
14
     * This method must always return a CacheItemInterface object, even in case of
15
     * a cache miss. It MUST NOT return null.
16
     *
17
     * @param string $key
18
     *            The key for which to return the corresponding Cache Item.
19
     *            
20
     * @throws InvalidArgumentException If the $key string is not a legal value a \Psr\Cache\InvalidArgumentException
21
     *         MUST be thrown.
22
     *        
23
     * @return CacheItemInterface
24
     */
25
    public function getItem($key)
26
    {
27
        return new CacheItem($key, null, false);
28
    }
29
30
    /**
31
     * Returns a traversable set of cache items.
32
     *
33
     * @param array $keys
34
     *            An indexed array of keys of items to retrieve.
35
     *            
36
     * @throws InvalidArgumentException If any of the keys in $keys are not a legal value a \Psr\Cache\InvalidArgumentException
37
     *         MUST be thrown.
38
     *        
39
     * @return array|\Traversable A traversable collection of Cache Items keyed by the cache keys of
40
     *         each item. A Cache item will be returned for each key, even if that
41
     *         key is not found. However, if no keys are specified then an empty
42
     *         traversable MUST be returned instead.
43
     */
44 View Code Duplication
    public function getItems(array $keys = [])
0 ignored issues
show
Duplication introduced by
This method seems to be duplicated in your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
45
    {
46
        $result = [];
47
        
48
        foreach ($keys as $key) {
49
            $result[$key] = $this->getItem($key);
50
        }
51
        
52
        return $result;
53
    }
54
55
    /**
56
     * Confirms if the cache contains specified cache item.
57
     *
58
     * Note: This method MAY avoid retrieving the cached value for performance reasons.
59
     * This could result in a race condition with CacheItemInterface::get(). To avoid
60
     * such situation use CacheItemInterface::isHit() instead.
61
     *
62
     * @param string $key
63
     *            The key for which to check existence.
64
     *            
65
     * @throws InvalidArgumentException If the $key string is not a legal value a \Psr\Cache\InvalidArgumentException
66
     *         MUST be thrown.
67
     *        
68
     * @return bool True if item exists in the cache, false otherwise.
69
     */
70
    public function hasItem($key)
71
    {
72
        return false;
73
    }
74
75
    /**
76
     * Deletes all items in the pool.
77
     *
78
     * @return bool True if the pool was successfully cleared. False if there was an error.
79
     */
80
    public function clear()
81
    {
82
        return true;
83
    }
84
85
    /**
86
     * Removes the item from the pool.
87
     *
88
     * @param string $key
89
     *            The key for which to delete
90
     *            
91
     * @throws InvalidArgumentException If the $key string is not a legal value a \Psr\Cache\InvalidArgumentException
92
     *         MUST be thrown.
93
     *        
94
     * @return bool True if the item was successfully removed. False if there was an error.
95
     */
96
    public function deleteItem($key)
97
    {
98
        return true;
99
    }
100
101
    /**
102
     * Removes multiple items from the pool.
103
     *
104
     * @param array $keys
105
     *            An array of keys that should be removed from the pool.
106
     *            
107
     * @throws InvalidArgumentException If any of the keys in $keys are not a legal value a \Psr\Cache\InvalidArgumentException
108
     *         MUST be thrown.
109
     *        
110
     * @return bool True if the items were successfully removed. False if there was an error.
111
     */
112
    public function deleteItems(array $keys)
113
    {
114
        return true;
115
    }
116
117
    /**
118
     * Persists a cache item immediately.
119
     *
120
     * @param CacheItemInterface $item
121
     *            The cache item to save.
122
     *            
123
     * @return bool True if the item was successfully persisted. False if there was an error.
124
     */
125
    public function save(CacheItemInterface $item)
126
    {
127
        return true;
128
    }
129
130
    /**
131
     * Sets a cache item to be persisted later.
132
     *
133
     * @param CacheItemInterface $item
134
     *            The cache item to save.
135
     *            
136
     * @return bool False if the item could not be queued or if a commit was attempted and failed. True otherwise.
137
     */
138
    public function saveDeferred(CacheItemInterface $item)
139
    {
140
        return true;
141
    }
142
143
    /**
144
     * Persists any deferred cache items.
145
     *
146
     * @return bool True if all not-yet-saved items were successfully saved or there were none. False otherwise.
147
     */
148
    public function commit()
149
    {
150
        return true;
151
    }
152
}
153