Duplicate code is one of the most pungent code smells. A rule that is often used is to re-structure code once it is duplicated in three or more places.
Common duplication problems, and corresponding solutions are:
1 | <?php |
||
22 | class Apcu extends AbstractCacheItemPool |
||
|
|||
23 | { |
||
24 | /** |
||
25 | * This will wipe out the entire cache's keys |
||
26 | * |
||
27 | * @return boolean True if the pool was successfully cleared. False if there was an error. |
||
28 | * |
||
29 | * @since __DEPLOY_VERSION__ |
||
30 | */ |
||
31 | public function clear() |
||
35 | |||
36 | /** |
||
37 | * Returns a Cache Item representing the specified key. |
||
38 | * |
||
39 | * @param string $key The key for which to return the corresponding Cache Item. |
||
40 | * |
||
41 | * @return CacheItemInterface The corresponding Cache Item. |
||
42 | * |
||
43 | * @since __DEPLOY_VERSION__ |
||
44 | */ |
||
45 | View Code Duplication | public function getItem($key) |
|
58 | |||
59 | /** |
||
60 | * Returns a traversable set of cache items. |
||
61 | * |
||
62 | * @param string[] $keys An indexed array of keys of items to retrieve. |
||
63 | * |
||
64 | * @return array A traversable collection of Cache Items keyed by the cache keys of each item. |
||
65 | * A Cache item will be returned for each key, even if that key is not found. |
||
66 | * |
||
67 | * @since __DEPLOY_VERSION__ |
||
68 | */ |
||
69 | public function getItems(array $keys = []) |
||
90 | |||
91 | /** |
||
92 | * Removes the item from the pool. |
||
93 | * |
||
94 | * @param string $key The key to delete. |
||
95 | * |
||
96 | * @return boolean True if the item was successfully removed. False if there was an error. |
||
97 | * |
||
98 | * @since __DEPLOY_VERSION__ |
||
99 | */ |
||
100 | public function deleteItem($key) |
||
110 | |||
111 | /** |
||
112 | * Persists a cache item immediately. |
||
113 | * |
||
114 | * @param CacheItemInterface $item The cache item to save. |
||
115 | * |
||
116 | * @return boolean True if the item was successfully persisted. False if there was an error. |
||
117 | * |
||
118 | * @since __DEPLOY_VERSION__ |
||
119 | */ |
||
120 | View Code Duplication | public function save(CacheItemInterface $item) |
|
134 | |||
135 | /** |
||
136 | * Confirms if the cache contains specified cache item. |
||
137 | * |
||
138 | * @param string $key The key for which to check existence. |
||
139 | * |
||
140 | * @return boolean True if item exists in the cache, false otherwise. |
||
141 | * |
||
142 | * @since __DEPLOY_VERSION__ |
||
143 | */ |
||
144 | public function hasItem($key) |
||
148 | |||
149 | /** |
||
150 | * Test to see if the CacheItemPoolInterface is available |
||
151 | * |
||
152 | * @return boolean True on success, false otherwise |
||
153 | * |
||
154 | * @since __DEPLOY_VERSION__ |
||
155 | */ |
||
156 | public static function isSupported(): bool |
||
168 | } |
||
169 |
This class, trait or interface has been deprecated. The supplier of the file has supplied an explanatory message.
The explanatory message should give you some clue as to whether and when the type will be removed from the class and what other constant to use instead.