Passed
Push — main ( 08f4bd...eac196 )
by Sílvio
01:15 queued 17s
created
src/Cacheer.php 2 patches
Indentation   +176 added lines, -176 removed lines patch added patch discarded remove patch
@@ -24,57 +24,57 @@  discard block
 block discarded – undo
24 24
 final class Cacheer implements CacheerInterface
25 25
 {
26 26
     /**
27
-    * @var string
28
-    */
27
+     * @var string
28
+     */
29 29
     private string $message;
30 30
 
31 31
     /**
32
-    * @var boolean
33
-    */
32
+     * @var boolean
33
+     */
34 34
     private bool $success;
35 35
 
36 36
     /**
37
-    * @var boolean
38
-    */
37
+     * @var boolean
38
+     */
39 39
     private bool $formatted = false;
40 40
 
41 41
     /**
42
-    * @var bool
43
-    */
42
+     * @var bool
43
+     */
44 44
     private bool $compression = false;
45 45
 
46 46
     /**
47
-    * @var string|null
48
-    */
47
+     * @var string|null
48
+     */
49 49
     private ?string $encryptionKey = null;
50 50
 
51 51
     /**
52
-    * @var FileCacheStore|DatabaseCacheStore|RedisCacheStore|ArrayCacheStore
53
-    */
52
+     * @var FileCacheStore|DatabaseCacheStore|RedisCacheStore|ArrayCacheStore
53
+     */
54 54
     public $cacheStore;
55 55
 
56 56
     /**
57
-    * @var array
58
-    */
57
+     * @var array
58
+     */
59 59
     public array $options = [];
60 60
 
61 61
     /**
62
-    * @var CacheRetriever
63
-    */
62
+     * @var CacheRetriever
63
+     */
64 64
     private CacheRetriever $retriever;
65 65
 
66 66
     /**
67
-    * @var CacheMutator
68
-    */
67
+     * @var CacheMutator
68
+     */
69 69
     private CacheMutator $mutator;
70 70
 
71 71
 /**
72
-    * Cacheer constructor.
73
-    *
74
-    * @param array $options
75
-    * @param bool  $formatted
76
-    * @throws RuntimeException
77
-    */
72
+ * Cacheer constructor.
73
+ *
74
+ * @param array $options
75
+ * @param bool  $formatted
76
+ * @throws RuntimeException
77
+ */
78 78
     public function __construct(array $options = [], bool $formatted = false)
79 79
     {
80 80
         $this->formatted = $formatted;
@@ -85,255 +85,255 @@  discard block
 block discarded – undo
85 85
     }
86 86
 
87 87
     /**
88
-    * Adds data to the cache if it does not already exist.
89
-    *
90
-    * @param string $cacheKey
91
-    * @param mixed  $cacheData
92
-    * @param string $namespace
93
-    * @param int|string $ttl
94
-    * @return bool
95
-    */
88
+     * Adds data to the cache if it does not already exist.
89
+     *
90
+     * @param string $cacheKey
91
+     * @param mixed  $cacheData
92
+     * @param string $namespace
93
+     * @param int|string $ttl
94
+     * @return bool
95
+     */
96 96
     public function add(string $cacheKey, mixed $cacheData, string $namespace = '', int|string $ttl = 3600): bool
97 97
     {
98 98
         return $this->mutator->add($cacheKey, $cacheData, $namespace, $ttl);
99 99
     }
100 100
 
101 101
     /**
102
-    * Appends data to an existing cache item.
103
-    * 
104
-    * @param string $cacheKey
105
-    * @param mixed  $cacheData
106
-    * @param string $namespace
107
-    * @return void
108
-    */
102
+     * Appends data to an existing cache item.
103
+     * 
104
+     * @param string $cacheKey
105
+     * @param mixed  $cacheData
106
+     * @param string $namespace
107
+     * @return void
108
+     */
109 109
     public function appendCache(string $cacheKey, mixed $cacheData, string $namespace = ''): void
110 110
     {
111 111
         $this->mutator->appendCache($cacheKey, $cacheData, $namespace);
112 112
     }
113 113
 
114 114
     /**
115
-    * Clears a specific cache item.
116
-    * 
117
-    * @param string $cacheKey
118
-    * @param string $namespace
119
-    * @return void
120
-    */
115
+     * Clears a specific cache item.
116
+     * 
117
+     * @param string $cacheKey
118
+     * @param string $namespace
119
+     * @return void
120
+     */
121 121
     public function clearCache(string $cacheKey, string $namespace = ''): void
122 122
     {
123 123
         $this->mutator->clearCache($cacheKey, $namespace);
124 124
     }
125 125
 
126 126
     /**
127
-    * Decrements a cache item by a specified amount.
128
-    *  
129
-    * @param string $cacheKey
130
-    * @param int $amount
131
-    * @param string $namespace
132
-    * @return bool
133
-    */
127
+     * Decrements a cache item by a specified amount.
128
+     *  
129
+     * @param string $cacheKey
130
+     * @param int $amount
131
+     * @param string $namespace
132
+     * @return bool
133
+     */
134 134
     public function decrement(string $cacheKey, int $amount = 1, string $namespace = ''): bool
135 135
     {
136 136
         return $this->mutator->decrement($cacheKey, $amount, $namespace);
137 137
     }
138 138
 
139 139
     /**
140
-    * Store data in the cache permanently.
141
-    *
142
-    * @param string $cacheKey
143
-    * @param mixed $cacheData
144
-    * @return void
145
-    */
140
+     * Store data in the cache permanently.
141
+     *
142
+     * @param string $cacheKey
143
+     * @param mixed $cacheData
144
+     * @return void
145
+     */
146 146
     public function forever(string $cacheKey, mixed $cacheData): void
147 147
     {
148 148
         $this->mutator->forever($cacheKey, $cacheData);
149 149
     }
150 150
 
151 151
     /**
152
-    * Flushes all cache items.
153
-    * 
154
-    * @return void
155
-    */
152
+     * Flushes all cache items.
153
+     * 
154
+     * @return void
155
+     */
156 156
     public function flushCache(): void
157 157
     {
158 158
         $this->mutator->flushCache();
159 159
     }
160 160
 
161 161
     /**
162
-    * Retrieves a cache item and deletes it from the cache.
163
-    * 
164
-    * @param string $cacheKey
165
-    * @param string $namespace
166
-    * @return mixed
167
-    */
162
+     * Retrieves a cache item and deletes it from the cache.
163
+     * 
164
+     * @param string $cacheKey
165
+     * @param string $namespace
166
+     * @return mixed
167
+     */
168 168
     public function getAndForget(string $cacheKey, string $namespace = ''): mixed
169 169
     {
170 170
         return $this->retriever->getAndForget($cacheKey, $namespace);
171 171
     }
172 172
 
173 173
     /**
174
-    * Gets all items in a specific namespace.
175
-    * 
176
-    * @param string $namespace
177
-    * @return CacheDataFormatter|mixed
178
-    */
174
+     * Gets all items in a specific namespace.
175
+     * 
176
+     * @param string $namespace
177
+     * @return CacheDataFormatter|mixed
178
+     */
179 179
     public function getAll(string $namespace = ''): mixed
180 180
     {
181 181
         return $this->retriever->getAll($namespace);
182 182
     }
183 183
 
184 184
     /**
185
-    * Retrieves a single cache item.
186
-    * 
187
-    * @param string $cacheKey
188
-    * @param string $namespace
189
-    * @param string|int $ttl
190
-    * @return CacheDataFormatter|mixed
191
-    */
185
+     * Retrieves a single cache item.
186
+     * 
187
+     * @param string $cacheKey
188
+     * @param string $namespace
189
+     * @param string|int $ttl
190
+     * @return CacheDataFormatter|mixed
191
+     */
192 192
     public function getCache(string $cacheKey, string $namespace = '', string|int $ttl = 3600): mixed
193 193
     {
194 194
         return $this->retriever->getCache($cacheKey, $namespace, $ttl);
195 195
     }
196 196
 
197 197
     /**
198
-    * Retrieves multiple cache items by their keys.
199
-    * 
200
-    * @param array $cacheKeys
201
-    * @param string $namespace
202
-    * @param string|int $ttl
203
-    * @return CacheDataFormatter|mixed
204
-    */
198
+     * Retrieves multiple cache items by their keys.
199
+     * 
200
+     * @param array $cacheKeys
201
+     * @param string $namespace
202
+     * @param string|int $ttl
203
+     * @return CacheDataFormatter|mixed
204
+     */
205 205
     public function getMany(array $cacheKeys, string $namespace = '', string|int $ttl = 3600): mixed
206 206
     {
207 207
         return $this->retriever->getMany($cacheKeys, $namespace, $ttl);
208 208
     }
209 209
 
210 210
     /**
211
-    * Checks if a cache item exists.
212
-    * 
213
-    * @param string $cacheKey
214
-    * @param string $namespace
215
-    * @return void
216
-    */
211
+     * Checks if a cache item exists.
212
+     * 
213
+     * @param string $cacheKey
214
+     * @param string $namespace
215
+     * @return void
216
+     */
217 217
     public function has(string $cacheKey, string $namespace = ''): void
218 218
     {
219 219
         $this->retriever->has($cacheKey, $namespace);
220 220
     }
221 221
 
222 222
     /**
223
-    * Increments a cache item by a specified amount.
224
-    * 
225
-    * @param string $cacheKey
226
-    * @param int $amount
227
-    * @param string $namespace
228
-    * @return bool
229
-    */
223
+     * Increments a cache item by a specified amount.
224
+     * 
225
+     * @param string $cacheKey
226
+     * @param int $amount
227
+     * @param string $namespace
228
+     * @return bool
229
+     */
230 230
     public function increment(string $cacheKey, int $amount = 1, string $namespace = ''): bool
231 231
     {
232 232
         return $this->mutator->increment($cacheKey, $amount, $namespace);
233 233
     }
234 234
 
235 235
     /**
236
-    * Checks if the last operation was successful.
237
-    * 
238
-    * @return bool
239
-    */
236
+     * Checks if the last operation was successful.
237
+     * 
238
+     * @return bool
239
+     */
240 240
     public function isSuccess(): bool
241 241
     {
242 242
         return $this->success;
243 243
     }
244 244
 
245 245
     /**
246
-    * Stores an item in the cache with a specific TTL.
247
-    * 
248
-    * @param string $cacheKey
249
-    * @param mixed  $cacheData
250
-    * @param string $namespace
251
-    * @param string|int $ttl
252
-    * @return void
253
-    */
246
+     * Stores an item in the cache with a specific TTL.
247
+     * 
248
+     * @param string $cacheKey
249
+     * @param mixed  $cacheData
250
+     * @param string $namespace
251
+     * @param string|int $ttl
252
+     * @return void
253
+     */
254 254
     public function putCache(string $cacheKey, mixed $cacheData, string $namespace = '', string|int $ttl = 3600): void
255 255
     {
256 256
         $this->mutator->putCache($cacheKey, $cacheData, $namespace, $ttl);
257 257
     }
258 258
 
259 259
     /**
260
-    * Stores multiple items in the cache.
261
-    *  
262
-    * @param array   $items
263
-    * @param string  $namespace
264
-    * @param integer $batchSize
265
-    * @return void
266
-    */
260
+     * Stores multiple items in the cache.
261
+     *  
262
+     * @param array   $items
263
+     * @param string  $namespace
264
+     * @param integer $batchSize
265
+     * @return void
266
+     */
267 267
     public function putMany(array $items, string $namespace = '', int $batchSize = 100): void
268 268
     {
269 269
         $this->mutator->putMany($items, $namespace, $batchSize);
270 270
     }
271 271
 
272 272
     /**
273
-    * Renews the cache for a specific key with a new TTL.
274
-    * 
275
-    * @param string $cacheKey
276
-    * @param string|int $ttl
277
-    * @param string $namespace
278
-    * @return void
279
-    */
273
+     * Renews the cache for a specific key with a new TTL.
274
+     * 
275
+     * @param string $cacheKey
276
+     * @param string|int $ttl
277
+     * @param string $namespace
278
+     * @return void
279
+     */
280 280
     public function renewCache(string $cacheKey, string|int $ttl = 3600, string $namespace = ''): void
281 281
     {
282 282
         $this->mutator->renewCache($cacheKey, $ttl, $namespace);
283 283
     }
284 284
 
285 285
     /**
286
-    * Retrieves a cache item or executes a callback to store it if not found.
287
-    * 
288
-    * @param string $cacheKey
289
-    * @param int|string $ttl
290
-    * @param Closure $callback
291
-    * @return mixed
292
-    */
286
+     * Retrieves a cache item or executes a callback to store it if not found.
287
+     * 
288
+     * @param string $cacheKey
289
+     * @param int|string $ttl
290
+     * @param Closure $callback
291
+     * @return mixed
292
+     */
293 293
     public function remember(string $cacheKey, int|string $ttl, Closure $callback): mixed
294 294
     {
295 295
         return $this->retriever->remember($cacheKey, $ttl, $callback);
296 296
     }
297 297
 
298 298
     /**
299
-    * Retrieves a cache item or executes a callback to store it permanently if not found.
300
-    * 
301
-    * @param string $cacheKey
302
-    * @param Closure $callback
303
-    * @return mixed
304
-    */
299
+     * Retrieves a cache item or executes a callback to store it permanently if not found.
300
+     * 
301
+     * @param string $cacheKey
302
+     * @param Closure $callback
303
+     * @return mixed
304
+     */
305 305
     public function rememberForever(string $cacheKey, Closure $callback): mixed
306 306
     {
307 307
         return $this->retriever->rememberForever($cacheKey, $callback);
308 308
     }
309 309
 
310 310
     /**
311
-    * Returns a CacheConfig instance for configuration management.
312
-    * 
313
-    * @return CacheConfig
314
-    */
311
+     * Returns a CacheConfig instance for configuration management.
312
+     * 
313
+     * @return CacheConfig
314
+     */
315 315
     public function setConfig(): CacheConfig
316 316
     {
317 317
         return new CacheConfig($this);
318 318
     }
319 319
 
320 320
     /**
321
-    * Sets the cache driver based on the configuration.
322
-    * 
323
-    * @return CacheDriver
324
-    */
321
+     * Sets the cache driver based on the configuration.
322
+     * 
323
+     * @return CacheDriver
324
+     */
325 325
     public function setDriver(): CacheDriver
326 326
     {
327 327
         return new CacheDriver($this);
328 328
     }
329 329
 
330 330
     /**
331
-    * Sets a message for the cache operation.
332
-    *
333
-    * @param string  $message
334
-    * @param boolean $success
335
-    * @return void
336
-    */
331
+     * Sets a message for the cache operation.
332
+     *
333
+     * @param string  $message
334
+     * @param boolean $success
335
+     * @return void
336
+     */
337 337
     private function setMessage(string $message, bool $success): void
338 338
     {
339 339
         $this->message = $message;
@@ -341,10 +341,10 @@  discard block
 block discarded – undo
341 341
     }
342 342
 
343 343
     /**
344
-    * Retrieves the message from the last operation.
345
-    * 
346
-    * @return string
347
-    */
344
+     * Retrieves the message from the last operation.
345
+     * 
346
+     * @return string
347
+     */
348 348
     public function getMessage(): string
349 349
     {
350 350
         return $this->message;
@@ -393,32 +393,32 @@  discard block
 block discarded – undo
393 393
     }
394 394
 
395 395
     /**
396
-    * Enables or disables the formatter for cache data.
397
-    * 
398
-    * @return void
399
-    */
396
+     * Enables or disables the formatter for cache data.
397
+     * 
398
+     * @return void
399
+     */
400 400
     public function useFormatter(): void
401 401
     {
402 402
         $this->formatted = !$this->formatted;
403 403
     }
404 404
 
405 405
     /**
406
-    * Validates the options provided for the Cacheer instance.
407
-    * 
408
-    * @param array $options
409
-    * @return void
410
-    */
406
+     * Validates the options provided for the Cacheer instance.
407
+     * 
408
+     * @param array $options
409
+     * @return void
410
+     */
411 411
     private function validateOptions(array $options): void
412 412
     {
413 413
         $this->options = $options;
414 414
     }
415 415
 
416 416
     /**
417
-    * Enable or disable data compression
418
-    *
419
-    * @param bool $status
420
-    * @return $this
421
-    */
417
+     * Enable or disable data compression
418
+     *
419
+     * @param bool $status
420
+     * @return $this
421
+     */
422 422
     public function useCompression(bool $status = true): Cacheer
423 423
     {
424 424
         $this->compression = $status;
@@ -426,11 +426,11 @@  discard block
 block discarded – undo
426 426
     }
427 427
 
428 428
     /**
429
-    * Enable encryption for cached data
430
-    *
431
-    * @param string $key
432
-    * @return $this
433
-    */
429
+     * Enable encryption for cached data
430
+     *
431
+     * @param string $key
432
+     * @return $this
433
+     */
434 434
     public function useEncryption(string $key): Cacheer
435 435
     {
436 436
         $this->encryptionKey = $key;
Please login to merge, or discard this patch.
Spacing   +6 added lines, -6 removed lines patch added patch discarded remove patch
@@ -93,7 +93,7 @@  discard block
 block discarded – undo
93 93
     * @param int|string $ttl
94 94
     * @return bool
95 95
     */
96
-    public function add(string $cacheKey, mixed $cacheData, string $namespace = '', int|string $ttl = 3600): bool
96
+    public function add(string $cacheKey, mixed $cacheData, string $namespace = '', int | string $ttl = 3600): bool
97 97
     {
98 98
         return $this->mutator->add($cacheKey, $cacheData, $namespace, $ttl);
99 99
     }
@@ -189,7 +189,7 @@  discard block
 block discarded – undo
189 189
     * @param string|int $ttl
190 190
     * @return CacheDataFormatter|mixed
191 191
     */
192
-    public function getCache(string $cacheKey, string $namespace = '', string|int $ttl = 3600): mixed
192
+    public function getCache(string $cacheKey, string $namespace = '', string | int $ttl = 3600): mixed
193 193
     {
194 194
         return $this->retriever->getCache($cacheKey, $namespace, $ttl);
195 195
     }
@@ -202,7 +202,7 @@  discard block
 block discarded – undo
202 202
     * @param string|int $ttl
203 203
     * @return CacheDataFormatter|mixed
204 204
     */
205
-    public function getMany(array $cacheKeys, string $namespace = '', string|int $ttl = 3600): mixed
205
+    public function getMany(array $cacheKeys, string $namespace = '', string | int $ttl = 3600): mixed
206 206
     {
207 207
         return $this->retriever->getMany($cacheKeys, $namespace, $ttl);
208 208
     }
@@ -251,7 +251,7 @@  discard block
 block discarded – undo
251 251
     * @param string|int $ttl
252 252
     * @return void
253 253
     */
254
-    public function putCache(string $cacheKey, mixed $cacheData, string $namespace = '', string|int $ttl = 3600): void
254
+    public function putCache(string $cacheKey, mixed $cacheData, string $namespace = '', string | int $ttl = 3600): void
255 255
     {
256 256
         $this->mutator->putCache($cacheKey, $cacheData, $namespace, $ttl);
257 257
     }
@@ -277,7 +277,7 @@  discard block
 block discarded – undo
277 277
     * @param string $namespace
278 278
     * @return void
279 279
     */
280
-    public function renewCache(string $cacheKey, string|int $ttl = 3600, string $namespace = ''): void
280
+    public function renewCache(string $cacheKey, string | int $ttl = 3600, string $namespace = ''): void
281 281
     {
282 282
         $this->mutator->renewCache($cacheKey, $ttl, $namespace);
283 283
     }
@@ -290,7 +290,7 @@  discard block
 block discarded – undo
290 290
     * @param Closure $callback
291 291
     * @return mixed
292 292
     */
293
-    public function remember(string $cacheKey, int|string $ttl, Closure $callback): mixed
293
+    public function remember(string $cacheKey, int | string $ttl, Closure $callback): mixed
294 294
     {
295 295
         return $this->retriever->remember($cacheKey, $ttl, $callback);
296 296
     }
Please login to merge, or discard this patch.