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 |
||
28 | class File extends AbstractCacheItemPool |
||
|
|||
29 | { |
||
30 | /** |
||
31 | * Constructor. |
||
32 | * |
||
33 | * @param mixed $options An options array, or an object that implements \ArrayAccess |
||
34 | * |
||
35 | * @since 1.0 |
||
36 | * @throws \RuntimeException |
||
37 | */ |
||
38 | 19 | public function __construct($options = []) |
|
54 | |||
55 | /** |
||
56 | * This will wipe out the entire cache's keys |
||
57 | * |
||
58 | * @return boolean True if the pool was successfully cleared. False if there was an error. |
||
59 | * |
||
60 | * @since 1.0 |
||
61 | */ |
||
62 | 19 | public function clear() |
|
85 | |||
86 | /** |
||
87 | * Returns a Cache Item representing the specified key. |
||
88 | * |
||
89 | * @param string $key The key for which to return the corresponding Cache Item. |
||
90 | * |
||
91 | * @return CacheItemInterface The corresponding Cache Item. |
||
92 | * |
||
93 | * @since __DEPLOY_VERSION__ |
||
94 | * @throws RuntimeException |
||
95 | */ |
||
96 | 12 | public function getItem($key) |
|
144 | |||
145 | /** |
||
146 | * Removes the item from the pool. |
||
147 | * |
||
148 | * @param string $key The key to delete. |
||
149 | * |
||
150 | * @return boolean True if the item was successfully removed. False if there was an error. |
||
151 | * |
||
152 | * @since __DEPLOY_VERSION__ |
||
153 | */ |
||
154 | 5 | public function deleteItem($key) |
|
164 | |||
165 | /** |
||
166 | * Persists a cache item immediately. |
||
167 | * |
||
168 | * @param CacheItemInterface $item The cache item to save. |
||
169 | * |
||
170 | * @return boolean True if the item was successfully persisted. False if there was an error. |
||
171 | * |
||
172 | * @since __DEPLOY_VERSION__ |
||
173 | */ |
||
174 | 16 | public function save(CacheItemInterface $item) |
|
201 | |||
202 | /** |
||
203 | * Confirms if the cache contains specified cache item. |
||
204 | * |
||
205 | * @param string $key The key for which to check existence. |
||
206 | * |
||
207 | * @return boolean True if item exists in the cache, false otherwise. |
||
208 | * |
||
209 | * @since 1.0 |
||
210 | */ |
||
211 | 16 | public function hasItem($key) |
|
215 | |||
216 | /** |
||
217 | * Test to see if the CacheItemPoolInterface is available |
||
218 | * |
||
219 | * @return boolean True on success, false otherwise |
||
220 | * |
||
221 | * @since __DEPLOY_VERSION__ |
||
222 | */ |
||
223 | public static function isSupported(): bool |
||
227 | |||
228 | /** |
||
229 | * Check that the file path is a directory and writable. |
||
230 | * |
||
231 | * @param string $filePath A file path. |
||
232 | * |
||
233 | * @return boolean The method will always return true, if it returns. |
||
234 | * |
||
235 | * @since 1.0 |
||
236 | * @throws RuntimeException if the file path is invalid. |
||
237 | */ |
||
238 | 19 | private function checkFilePath($filePath) |
|
252 | |||
253 | /** |
||
254 | * Get the full stream URI for the cache entry. |
||
255 | * |
||
256 | * @param string $key The storage entry identifier. |
||
257 | * |
||
258 | * @return string The full stream URI for the cache entry. |
||
259 | * |
||
260 | * @since 1.0 |
||
261 | * @throws \RuntimeException if the cache path is invalid. |
||
262 | 16 | */ |
|
263 | private function fetchStreamUri($key) |
||
275 | } |
||
276 |
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.