Passed
Push — main ( a8c6a0...1905a9 )
by Sílvio
01:03 queued 16s
created
src/Config/Option/Builder/OptionBuilder.php 1 patch
Indentation   +8 added lines, -8 removed lines patch added patch discarded remove patch
@@ -12,13 +12,13 @@
 block discarded – undo
12 12
 class OptionBuilder
13 13
 {
14 14
   
15
-  /**
16
-  * Creates a FileOptionBuilder instance for file-based cache options.
17
-  *
18
-  * @return FileOptionBuilder
19
-  */
20
-  public static function forFile() 
21
-  {
15
+    /**
16
+     * Creates a FileOptionBuilder instance for file-based cache options.
17
+     *
18
+     * @return FileOptionBuilder
19
+     */
20
+    public static function forFile() 
21
+    {
22 22
     return new FileOptionBuilder();
23
-  }
23
+    }
24 24
 }
Please login to merge, or discard this patch.
src/CacheStore/ArrayCacheStore.php 2 patches
Indentation   +289 added lines, -289 removed lines patch added patch discarded remove patch
@@ -13,341 +13,341 @@  discard block
 block discarded – undo
13 13
 class ArrayCacheStore implements CacheerInterface
14 14
 {
15 15
 
16
-  /**
17
-  * @param array $arrayStore
18
-  */
19
-  private array $arrayStore = [];
20
-
21
-  /**
22
-   * @param boolean
23
-   */
24
-  private bool $success = false;
25
-
26
-  /**
27
-   * @param string
28
-   */
29
-  private string $message = '';
30
-
31
-  /**
32
-   * @var CacheLogger
33
-   */
34
-  private $logger = null;
35
-
36
-  /**
37
-   * ArrayCacheStore constructor.
38
-   * 
39
-   * @param string $logPath
40
-   */
41
-  public function __construct(string $logPath)
42
-  {
16
+    /**
17
+     * @param array $arrayStore
18
+     */
19
+    private array $arrayStore = [];
20
+
21
+    /**
22
+     * @param boolean
23
+     */
24
+    private bool $success = false;
25
+
26
+    /**
27
+     * @param string
28
+     */
29
+    private string $message = '';
30
+
31
+    /**
32
+     * @var CacheLogger
33
+     */
34
+    private $logger = null;
35
+
36
+    /**
37
+     * ArrayCacheStore constructor.
38
+     * 
39
+     * @param string $logPath
40
+     */
41
+    public function __construct(string $logPath)
42
+    {
43 43
     $this->logger = new CacheLogger($logPath);
44
-  }
45
-
46
-  /**
47
-   * Appends data to an existing cache item.
48
-   * 
49
-   * @param string $cacheKey
50
-   * @param mixed  $cacheData
51
-   * @param string $namespace
52
-   * @return bool
53
-   */
54
-  public function appendCache(string $cacheKey, mixed $cacheData, string $namespace = '')
55
-  {
56
-      $arrayStoreKey = $this->buildArrayKey($cacheKey, $namespace);
57
-
58
-      if (!$this->has($cacheKey, $namespace)) {
59
-          $this->setMessage("cacheData can't be appended, because doesn't exist or expired", false);
60
-          $this->logger->debug("{$this->getMessage()} from array driver.");
61
-          return false;
62
-      }
63
-
64
-      $this->arrayStore[$arrayStoreKey]['cacheData'] = serialize($cacheData);
65
-      $this->setMessage("Cache appended successfully", true);
66
-      return true;
67
-  }
68
-
69
-  /**
70
-   * Builds a unique key for the array store.
71
-   * 
72
-   * @param string $cacheKey
73
-   * @param string $namespace
74
-   * @return string
75
-   */
76
-  private function buildArrayKey(string $cacheKey, string $namespace = '')
77
-  {
44
+    }
45
+
46
+    /**
47
+     * Appends data to an existing cache item.
48
+     * 
49
+     * @param string $cacheKey
50
+     * @param mixed  $cacheData
51
+     * @param string $namespace
52
+     * @return bool
53
+     */
54
+    public function appendCache(string $cacheKey, mixed $cacheData, string $namespace = '')
55
+    {
56
+        $arrayStoreKey = $this->buildArrayKey($cacheKey, $namespace);
57
+
58
+        if (!$this->has($cacheKey, $namespace)) {
59
+            $this->setMessage("cacheData can't be appended, because doesn't exist or expired", false);
60
+            $this->logger->debug("{$this->getMessage()} from array driver.");
61
+            return false;
62
+        }
63
+
64
+        $this->arrayStore[$arrayStoreKey]['cacheData'] = serialize($cacheData);
65
+        $this->setMessage("Cache appended successfully", true);
66
+        return true;
67
+    }
68
+
69
+    /**
70
+     * Builds a unique key for the array store.
71
+     * 
72
+     * @param string $cacheKey
73
+     * @param string $namespace
74
+     * @return string
75
+     */
76
+    private function buildArrayKey(string $cacheKey, string $namespace = '')
77
+    {
78 78
     return !empty($namespace) ? ($namespace . ':' . $cacheKey) : $cacheKey;
79
-  }
80
-
81
-  /**
82
-   * Clears a specific cache item.
83
-   * 
84
-   * @param string $cacheKey
85
-   * @param string $namespace
86
-   * @return void
87
-   */
88
-  public function clearCache(string $cacheKey, string $namespace = '')
89
-  {
79
+    }
80
+
81
+    /**
82
+     * Clears a specific cache item.
83
+     * 
84
+     * @param string $cacheKey
85
+     * @param string $namespace
86
+     * @return void
87
+     */
88
+    public function clearCache(string $cacheKey, string $namespace = '')
89
+    {
90 90
     $arrayStoreKey = $this->buildArrayKey($cacheKey, $namespace);
91 91
     unset($this->arrayStore[$arrayStoreKey]);
92 92
     $this->setMessage("Cache cleared successfully", true);
93 93
     $this->logger->debug("{$this->getMessage()} from array driver.");
94
-  }
95
-
96
-  /**
97
-   * Decrements a cache item by a specified amount.
98
-   * 
99
-   * @param string $cacheKey
100
-   * @param int $amount
101
-   * @param string $namespace
102
-   * @return bool
103
-   */
104
-  public function decrement(string $cacheKey, int $amount = 1, string $namespace = '')
105
-  {
94
+    }
95
+
96
+    /**
97
+     * Decrements a cache item by a specified amount.
98
+     * 
99
+     * @param string $cacheKey
100
+     * @param int $amount
101
+     * @param string $namespace
102
+     * @return bool
103
+     */
104
+    public function decrement(string $cacheKey, int $amount = 1, string $namespace = '')
105
+    {
106 106
     return $this->increment($cacheKey, ($amount * -1), $namespace);
107
-  }
108
-
109
-  /**
110
-   * Flushes all cache items.
111
-   * 
112
-   * @return void
113
-   */
114
-  public function flushCache()
115
-  {
107
+    }
108
+
109
+    /**
110
+     * Flushes all cache items.
111
+     * 
112
+     * @return void
113
+     */
114
+    public function flushCache()
115
+    {
116 116
     unset($this->arrayStore);
117 117
     $this->arrayStore = [];
118 118
     $this->setMessage("Cache flushed successfully", true);
119 119
     $this->logger->debug("{$this->getMessage()} from array driver.");
120
-  }
121
-
122
-  /**
123
-   * Stores a cache item permanently.
124
-   * 
125
-   * @param string $cacheKey
126
-   * @param mixed $cacheData
127
-   * @param string $namespace
128
-   * @param int|string $ttl
129
-   * @return void
130
-   */
131
-  public function forever(string $cacheKey, mixed $cacheData)
132
-  {
120
+    }
121
+
122
+    /**
123
+     * Stores a cache item permanently.
124
+     * 
125
+     * @param string $cacheKey
126
+     * @param mixed $cacheData
127
+     * @param string $namespace
128
+     * @param int|string $ttl
129
+     * @return void
130
+     */
131
+    public function forever(string $cacheKey, mixed $cacheData)
132
+    {
133 133
     $this->putCache($cacheKey, $cacheData, ttl: 31536000 * 1000);
134 134
     $this->setMessage($this->getMessage(), $this->isSuccess());
135
-  }
136
-
137
-  /**
138
-   * Retrieves a single cache item.
139
-   * 
140
-   * @param string $cacheKey
141
-   * @param string $namespace
142
-   * @param int|string $ttl
143
-   * @return mixed
144
-   */
145
-  public function getCache(string $cacheKey, string $namespace = '', string|int $ttl = 3600)
146
-  {
135
+    }
136
+
137
+    /**
138
+     * Retrieves a single cache item.
139
+     * 
140
+     * @param string $cacheKey
141
+     * @param string $namespace
142
+     * @param int|string $ttl
143
+     * @return mixed
144
+     */
145
+    public function getCache(string $cacheKey, string $namespace = '', string|int $ttl = 3600)
146
+    {
147 147
     $arrayStoreKey = $this->buildArrayKey($cacheKey, $namespace);
148 148
 
149 149
     if (!$this->has($cacheKey, $namespace)) {
150
-      $this->handleCacheNotFound();
151
-      return false;
150
+        $this->handleCacheNotFound();
151
+        return false;
152 152
     }
153 153
 
154 154
     $cacheData = $this->arrayStore[$arrayStoreKey];
155 155
     if ($this->isExpired($cacheData)) {
156
-      $this->handleCacheExpired($arrayStoreKey);
157
-      return false;
156
+        $this->handleCacheExpired($arrayStoreKey);
157
+        return false;
158 158
     }
159 159
 
160 160
     $this->setMessage("Cache retrieved successfully", true);
161 161
     $this->logger->debug("{$this->getMessage()} from array driver.");
162 162
     return $this->serialize($cacheData['cacheData'], false);
163
-  }
164
-
165
-  /**
166
-   * Verify if the cache is expired.
167
-   * 
168
-   * @param array $cacheData
169
-   * @return bool
170
-   */
171
-  private function isExpired(array $cacheData): bool
172
-  {
163
+    }
164
+
165
+    /**
166
+     * Verify if the cache is expired.
167
+     * 
168
+     * @param array $cacheData
169
+     * @return bool
170
+     */
171
+    private function isExpired(array $cacheData): bool
172
+    {
173 173
     $expirationTime = $cacheData['expirationTime'] ?? 0;
174 174
     $now = time();
175 175
     return $expirationTime !== 0 && $now >= $expirationTime;
176
-  }
177
-
178
-  /**
179
-   * Handles the case when cache data is not found.
180
-   * 
181
-   * @return void
182
-   */
183
-  private function handleCacheNotFound()
184
-  {
176
+    }
177
+
178
+    /**
179
+     * Handles the case when cache data is not found.
180
+     * 
181
+     * @return void
182
+     */
183
+    private function handleCacheNotFound()
184
+    {
185 185
     $this->setMessage("cacheData not found, does not exists or expired", false);
186 186
     $this->logger->debug("{$this->getMessage()} from array driver.");
187
-  }
188
-
189
-  /**
190
-   * Handles the case when cache data has expired.
191
-   * 
192
-   * @param string $arrayStoreKey
193
-   * @return void
194
-   */
195
-  private function handleCacheExpired(string $arrayStoreKey)
196
-  {
187
+    }
188
+
189
+    /**
190
+     * Handles the case when cache data has expired.
191
+     * 
192
+     * @param string $arrayStoreKey
193
+     * @return void
194
+     */
195
+    private function handleCacheExpired(string $arrayStoreKey)
196
+    {
197 197
     $parts = explode(':', $arrayStoreKey, 2);
198 198
     if (count($parts) === 2) {
199
-      list($np, $key) = $parts;
199
+        list($np, $key) = $parts;
200 200
     } else {
201
-      $np = '';
202
-      $key = $arrayStoreKey;
201
+        $np = '';
202
+        $key = $arrayStoreKey;
203 203
     }
204 204
     $this->clearCache($key, $np);
205 205
     $this->setMessage("cacheKey: {$key} has expired.", false);
206 206
     $this->logger->debug("{$this->getMessage()} from array driver.");
207
-  }
208
-
209
-  /**
210
-   * Gets all items in a specific namespace.
211
-   * 
212
-   * @param string $namespace
213
-   * @return array
214
-   */
215
-  public function getAll(string $namespace = '')
216
-  {
207
+    }
208
+
209
+    /**
210
+     * Gets all items in a specific namespace.
211
+     * 
212
+     * @param string $namespace
213
+     * @return array
214
+     */
215
+    public function getAll(string $namespace = '')
216
+    {
217 217
     $results = [];
218 218
     foreach ($this->arrayStore as $key => $data) {
219
-      if (strpos($key, $namespace . ':') === 0 || empty($namespace)) {
219
+        if (strpos($key, $namespace . ':') === 0 || empty($namespace)) {
220 220
         $results[$key] = $this->serialize($data['cacheData'], false);
221
-      }
221
+        }
222 222
     }
223 223
     return $results;
224
-  }
225
-
226
-  /**
227
-   * Retrieves multiple cache items by their keys.
228
-   * 
229
-   * @param array $cacheKeys
230
-   * @param string $namespace
231
-   * @param string|int $ttl
232
-   * @return array
233
-   */
234
-  public function getMany(array $cacheKeys, string $namespace = '', string|int $ttl = 3600)
235
-  {
224
+    }
225
+
226
+    /**
227
+     * Retrieves multiple cache items by their keys.
228
+     * 
229
+     * @param array $cacheKeys
230
+     * @param string $namespace
231
+     * @param string|int $ttl
232
+     * @return array
233
+     */
234
+    public function getMany(array $cacheKeys, string $namespace = '', string|int $ttl = 3600)
235
+    {
236 236
     $results = [];
237 237
     foreach ($cacheKeys as $cacheKey) {
238
-      $results[$cacheKey] = $this->getCache($cacheKey, $namespace, $ttl);
238
+        $results[$cacheKey] = $this->getCache($cacheKey, $namespace, $ttl);
239 239
     }
240 240
     return $results;
241
-  }
242
-
243
-  /**
244
-   * Checks if a cache item exists.
245
-   * 
246
-   * @param string $cacheKey
247
-   * @param string $namespace
248
-   * @return bool
249
-   */
250
-  public function has(string $cacheKey, string $namespace = '')
251
-  {
241
+    }
242
+
243
+    /**
244
+     * Checks if a cache item exists.
245
+     * 
246
+     * @param string $cacheKey
247
+     * @param string $namespace
248
+     * @return bool
249
+     */
250
+    public function has(string $cacheKey, string $namespace = '')
251
+    {
252 252
     $arrayStoreKey = $this->buildArrayKey($cacheKey, $namespace);
253 253
     return isset($this->arrayStore[$arrayStoreKey]) && time() < $this->arrayStore[$arrayStoreKey]['expirationTime'];
254
-  }
255
-
256
-  /**
257
-   * Increments a cache item by a specified amount.
258
-   * 
259
-   * @param string $cacheKey
260
-   * @param int $amount
261
-   * @param string $namespace
262
-   * @return bool
263
-   */
264
-  public function increment(string $cacheKey, int $amount = 1, string $namespace = '')
265
-  {
254
+    }
255
+
256
+    /**
257
+     * Increments a cache item by a specified amount.
258
+     * 
259
+     * @param string $cacheKey
260
+     * @param int $amount
261
+     * @param string $namespace
262
+     * @return bool
263
+     */
264
+    public function increment(string $cacheKey, int $amount = 1, string $namespace = '')
265
+    {
266 266
     $cacheData = $this->getCache($cacheKey, $namespace);
267 267
 
268 268
     if(!empty($cacheData) && is_numeric($cacheData)) {
269
-      $this->putCache($cacheKey, (int)($cacheData + $amount), $namespace);
270
-      $this->setMessage($this->getMessage(), $this->isSuccess());
271
-      return true;
269
+        $this->putCache($cacheKey, (int)($cacheData + $amount), $namespace);
270
+        $this->setMessage($this->getMessage(), $this->isSuccess());
271
+        return true;
272 272
     }
273 273
 
274 274
     return false;
275
-  }
276
-
277
-  /**
278
-   * Checks if the operation was successful.
279
-   * 
280
-   * @return boolean
281
-   */
282
-  public function isSuccess()
283
-  {
275
+    }
276
+
277
+    /**
278
+     * Checks if the operation was successful.
279
+     * 
280
+     * @return boolean
281
+     */
282
+    public function isSuccess()
283
+    {
284 284
     return $this->success;
285
-  }
286
-
287
-  /**
288
-   * Gets the last message.
289
-   * 
290
-   * @return string
291
-   */
292
-  public function getMessage()
293
-  {
285
+    }
286
+
287
+    /**
288
+     * Gets the last message.
289
+     * 
290
+     * @return string
291
+     */
292
+    public function getMessage()
293
+    {
294 294
     return $this->message;
295
-  }
296
-
297
-  /**
298
-   * Stores an item in the cache with a specific TTL.
299
-   * 
300
-   * @param string $cacheKey
301
-   * @param mixed $cacheData
302
-   * @param string $namespace
303
-   * @param int|string $ttl
304
-   * @return bool
305
-   */
306
-  public function putCache(string $cacheKey, mixed $cacheData, string $namespace = '', int|string $ttl = 3600)
307
-  {
295
+    }
296
+
297
+    /**
298
+     * Stores an item in the cache with a specific TTL.
299
+     * 
300
+     * @param string $cacheKey
301
+     * @param mixed $cacheData
302
+     * @param string $namespace
303
+     * @param int|string $ttl
304
+     * @return bool
305
+     */
306
+    public function putCache(string $cacheKey, mixed $cacheData, string $namespace = '', int|string $ttl = 3600)
307
+    {
308 308
     $arrayStoreKey = $this->buildArrayKey($cacheKey, $namespace);
309 309
 
310 310
     $this->arrayStore[$arrayStoreKey] = [
311
-      'cacheData' => serialize($cacheData),
312
-      'expirationTime' => time() + $ttl
311
+        'cacheData' => serialize($cacheData),
312
+        'expirationTime' => time() + $ttl
313 313
     ];
314 314
 
315 315
     $this->setMessage("Cache stored successfully", true);
316 316
     $this->logger->debug("{$this->getMessage()} from Array driver.");
317 317
     return true;
318
-  }
319
-
320
-  /**
321
-   * Stores multiple items in the cache in batches.
322
-   * 
323
-   * @param array $items
324
-   * @param string $namespace
325
-   * @param int $batchSize
326
-   * @return void
327
-   */
328
-  public function putMany(array $items, string $namespace = '', int $batchSize = 100)
329
-  {
318
+    }
319
+
320
+    /**
321
+     * Stores multiple items in the cache in batches.
322
+     * 
323
+     * @param array $items
324
+     * @param string $namespace
325
+     * @param int $batchSize
326
+     * @return void
327
+     */
328
+    public function putMany(array $items, string $namespace = '', int $batchSize = 100)
329
+    {
330 330
     $chunks = array_chunk($items, $batchSize, true);
331 331
 
332 332
     foreach ($chunks as $chunk) {
333
-      foreach ($chunk as $key => $data) {
334
-          $this->putCache($data['cacheKey'], $data['cacheData'], $namespace);
333
+        foreach ($chunk as $key => $data) {
334
+            $this->putCache($data['cacheKey'], $data['cacheData'], $namespace);
335
+        }
335 336
         }
336
-      }
337 337
     $this->setMessage("{$this->getMessage()}", $this->isSuccess());
338 338
     $this->logger->debug("{$this->getMessage()} from Array driver.");
339
-  }
340
-
341
-  /**
342
-   * Renews the expiration time of a cache item.
343
-   * 
344
-   * @param string $cacheKey
345
-   * @param string|int $ttl
346
-   * @param string $namespace
347
-   * @return void
348
-   */
349
-  public function renewCache(string $cacheKey, int|string $ttl = 3600, string $namespace = '')
350
-  {
339
+    }
340
+
341
+    /**
342
+     * Renews the expiration time of a cache item.
343
+     * 
344
+     * @param string $cacheKey
345
+     * @param string|int $ttl
346
+     * @param string $namespace
347
+     * @return void
348
+     */
349
+    public function renewCache(string $cacheKey, int|string $ttl = 3600, string $namespace = '')
350
+    {
351 351
     $arrayStoreKey = $this->buildArrayKey($cacheKey, $namespace);
352 352
 
353 353
     if (isset($this->arrayStore[$arrayStoreKey])) {
@@ -355,31 +355,31 @@  discard block
 block discarded – undo
355 355
         $this->arrayStore[$arrayStoreKey]['expirationTime'] = time() + $ttlSeconds;
356 356
         $this->setMessage("cacheKey: {$cacheKey} renewed successfully", true);
357 357
         $this->logger->debug("{$this->getMessage()} from array driver.");
358
-      }
359
-  }
360
-
361
-  /**
362
-   * Sets a message and its success status.
363
-   * 
364
-   * @param string  $message
365
-   * @param boolean $success
366
-   * @return void
367
-   */
368
-  private function setMessage(string $message, bool $success)
369
-  {
358
+        }
359
+    }
360
+
361
+    /**
362
+     * Sets a message and its success status.
363
+     * 
364
+     * @param string  $message
365
+     * @param boolean $success
366
+     * @return void
367
+     */
368
+    private function setMessage(string $message, bool $success)
369
+    {
370 370
     $this->message = $message;
371 371
     $this->success = $success;
372
-  }
373
-
374
-  /**
375
-   * Serializes or unserializes data based on the flag.
376
-   * 
377
-   * @param mixed $data
378
-   * @param bool $serialize
379
-   * @return mixed
380
-   */
381
-  private function serialize(mixed $data, bool $serialize = true)
382
-  {
372
+    }
373
+
374
+    /**
375
+     * Serializes or unserializes data based on the flag.
376
+     * 
377
+     * @param mixed $data
378
+     * @param bool $serialize
379
+     * @return mixed
380
+     */
381
+    private function serialize(mixed $data, bool $serialize = true)
382
+    {
383 383
     return $serialize ? serialize($data) : unserialize($data);
384
-  }
384
+    }
385 385
 }
Please login to merge, or discard this patch.
Spacing   +6 added lines, -6 removed lines patch added patch discarded remove patch
@@ -142,7 +142,7 @@  discard block
 block discarded – undo
142 142
    * @param int|string $ttl
143 143
    * @return mixed
144 144
    */
145
-  public function getCache(string $cacheKey, string $namespace = '', string|int $ttl = 3600)
145
+  public function getCache(string $cacheKey, string $namespace = '', string | int $ttl = 3600)
146 146
   {
147 147
     $arrayStoreKey = $this->buildArrayKey($cacheKey, $namespace);
148 148
 
@@ -231,7 +231,7 @@  discard block
 block discarded – undo
231 231
    * @param string|int $ttl
232 232
    * @return array
233 233
    */
234
-  public function getMany(array $cacheKeys, string $namespace = '', string|int $ttl = 3600)
234
+  public function getMany(array $cacheKeys, string $namespace = '', string | int $ttl = 3600)
235 235
   {
236 236
     $results = [];
237 237
     foreach ($cacheKeys as $cacheKey) {
@@ -265,7 +265,7 @@  discard block
 block discarded – undo
265 265
   {
266 266
     $cacheData = $this->getCache($cacheKey, $namespace);
267 267
 
268
-    if(!empty($cacheData) && is_numeric($cacheData)) {
268
+    if (!empty($cacheData) && is_numeric($cacheData)) {
269 269
       $this->putCache($cacheKey, (int)($cacheData + $amount), $namespace);
270 270
       $this->setMessage($this->getMessage(), $this->isSuccess());
271 271
       return true;
@@ -303,7 +303,7 @@  discard block
 block discarded – undo
303 303
    * @param int|string $ttl
304 304
    * @return bool
305 305
    */
306
-  public function putCache(string $cacheKey, mixed $cacheData, string $namespace = '', int|string $ttl = 3600)
306
+  public function putCache(string $cacheKey, mixed $cacheData, string $namespace = '', int | string $ttl = 3600)
307 307
   {
308 308
     $arrayStoreKey = $this->buildArrayKey($cacheKey, $namespace);
309 309
 
@@ -346,12 +346,12 @@  discard block
 block discarded – undo
346 346
    * @param string $namespace
347 347
    * @return void
348 348
    */
349
-  public function renewCache(string $cacheKey, int|string $ttl = 3600, string $namespace = '')
349
+  public function renewCache(string $cacheKey, int | string $ttl = 3600, string $namespace = '')
350 350
   {
351 351
     $arrayStoreKey = $this->buildArrayKey($cacheKey, $namespace);
352 352
 
353 353
     if (isset($this->arrayStore[$arrayStoreKey])) {
354
-        $ttlSeconds = is_numeric($ttl) ? (int) $ttl : strtotime($ttl) - time();
354
+        $ttlSeconds = is_numeric($ttl) ? (int)$ttl : strtotime($ttl) - time();
355 355
         $this->arrayStore[$arrayStoreKey]['expirationTime'] = time() + $ttlSeconds;
356 356
         $this->setMessage("cacheKey: {$cacheKey} renewed successfully", true);
357 357
         $this->logger->debug("{$this->getMessage()} from array driver.");
Please login to merge, or discard this patch.
src/Exceptions/CacheRedisException.php 1 patch
Indentation   +10 added lines, -10 removed lines patch added patch discarded remove patch
@@ -53,24 +53,24 @@
 block discarded – undo
53 53
     }
54 54
     
55 55
     /**
56
-    * Converts the exception to a JSON serializable format.
57
-    *
58
-    * @return string
59
-    */
56
+     * Converts the exception to a JSON serializable format.
57
+     *
58
+     * @return string
59
+     */
60 60
     public function jsonSerialize(): array
61 61
     {
62 62
         return parent::jsonSerialize();
63 63
     }
64 64
 
65 65
     /**
66
-    * Converts the exception to a JSON string.
67
-    *
68
-    * @param int $options
69
-    * @return string
70
-    */
66
+     * Converts the exception to a JSON string.
67
+     *
68
+     * @param int $options
69
+     * @return string
70
+     */
71 71
     public function toJson(int $options = 0)
72 72
     {
73
-      return parent::toJson($options);
73
+        return parent::toJson($options);
74 74
     }
75 75
 }
76 76
 
Please login to merge, or discard this patch.
src/Exceptions/ConnectionException.php 1 patch
Indentation   +10 added lines, -10 removed lines patch added patch discarded remove patch
@@ -53,23 +53,23 @@
 block discarded – undo
53 53
     }
54 54
     
55 55
     /**
56
-    * Converts the exception to a JSON serializable format.
57
-    * 
58
-    * @return string
59
-    */
56
+     * Converts the exception to a JSON serializable format.
57
+     * 
58
+     * @return string
59
+     */
60 60
     public function jsonSerialize(): array
61 61
     {
62 62
         return parent::jsonSerialize();
63 63
     }
64 64
 
65 65
     /**
66
-    * Converts the exception to a JSON string.
67
-    *
68
-    * @param int $options
69
-    * @return string
70
-    */
66
+     * Converts the exception to a JSON string.
67
+     *
68
+     * @param int $options
69
+     * @return string
70
+     */
71 71
     public function toJson(int $options = 0)
72 72
     {
73
-      return parent::toJson($options);
73
+        return parent::toJson($options);
74 74
     }
75 75
 }
Please login to merge, or discard this patch.
src/Cacheer.php 2 patches
Indentation   +172 added lines, -172 removed lines patch added patch discarded remove patch
@@ -22,47 +22,47 @@  discard block
 block discarded – undo
22 22
 final class Cacheer implements CacheerInterface
23 23
 {
24 24
     /**
25
-    * @var string
26
-    */
25
+     * @var string
26
+     */
27 27
     private string $message;
28 28
 
29 29
     /**
30
-    * @var boolean
31
-    */
30
+     * @var boolean
31
+     */
32 32
     private bool $success;
33 33
 
34 34
     /**
35
-    * @var boolean
36
-    */
35
+     * @var boolean
36
+     */
37 37
     private bool $formatted = false;
38 38
 
39 39
     /**
40
-    * @var bool
41
-    */
40
+     * @var bool
41
+     */
42 42
     private bool $compression = false;
43 43
 
44 44
     /**
45
-    * @var string|null
46
-    */
45
+     * @var string|null
46
+     */
47 47
     private ?string $encryptionKey = null;
48 48
 
49 49
     /**
50
-    * @var FileCacheStore|DatabaseCacheStore|RedisCacheStore|ArrayCacheStore
51
-    */
50
+     * @var FileCacheStore|DatabaseCacheStore|RedisCacheStore|ArrayCacheStore
51
+     */
52 52
     public $cacheStore;
53 53
 
54 54
     /**
55
-    * @var array
56
-    */
55
+     * @var array
56
+     */
57 57
     public array $options = [];
58 58
 
59 59
     /**
60
-    * Cacheer constructor.
61
-    *
62
-    * @param array $options
63
-    * @param bool  $formatted
64
-    * @throws RuntimeException
65
-    */
60
+     * Cacheer constructor.
61
+     *
62
+     * @param array $options
63
+     * @param bool  $formatted
64
+     * @throws RuntimeException
65
+     */
66 66
     public function __construct(array $options = [], $formatted = false)
67 67
     {
68 68
         $this->formatted = $formatted;
@@ -71,14 +71,14 @@  discard block
 block discarded – undo
71 71
     }
72 72
 
73 73
     /**
74
-    * Adds data to the cache if it does not already exist.
75
-    *
76
-    * @param string $cacheKey
77
-    * @param mixed  $cacheData
78
-    * @param string $namespace
79
-    * @param int|string $ttl
80
-    * @return bool
81
-    */
74
+     * Adds data to the cache if it does not already exist.
75
+     *
76
+     * @param string $cacheKey
77
+     * @param mixed  $cacheData
78
+     * @param string $namespace
79
+     * @param int|string $ttl
80
+     * @return bool
81
+     */
82 82
     public function add(string $cacheKey, mixed $cacheData, string $namespace = '', int|string $ttl = 3600)
83 83
     {
84 84
         if (!empty($this->getCache($cacheKey, $namespace))) {
@@ -92,13 +92,13 @@  discard block
 block discarded – undo
92 92
     }
93 93
 
94 94
     /**
95
-    * Appends data to an existing cache item.
96
-    * 
97
-    * @param string $cacheKey
98
-    * @param mixed  $cacheData
99
-    * @param string $namespace
100
-    * @return void
101
-    */
95
+     * Appends data to an existing cache item.
96
+     * 
97
+     * @param string $cacheKey
98
+     * @param mixed  $cacheData
99
+     * @param string $namespace
100
+     * @return void
101
+     */
102 102
     public function appendCache(string $cacheKey, mixed $cacheData, string $namespace = '')
103 103
     {
104 104
         $this->cacheStore->appendCache($cacheKey, $cacheData, $namespace);
@@ -106,12 +106,12 @@  discard block
 block discarded – undo
106 106
     }
107 107
 
108 108
     /**
109
-    * Clears a specific cache item.
110
-    * 
111
-    * @param string $cacheKey
112
-    * @param string $namespace
113
-    * @return void
114
-    */
109
+     * Clears a specific cache item.
110
+     * 
111
+     * @param string $cacheKey
112
+     * @param string $namespace
113
+     * @return void
114
+     */
115 115
     public function clearCache(string $cacheKey, string $namespace = '')
116 116
     {
117 117
         $this->cacheStore->clearCache($cacheKey, $namespace);
@@ -119,25 +119,25 @@  discard block
 block discarded – undo
119 119
     }
120 120
 
121 121
     /**
122
-    * Decrements a cache item by a specified amount.
123
-    *  
124
-    * @param string $cacheKey
125
-    * @param int $amount
126
-    * @param string $namespace
127
-    * @return bool
128
-    */
122
+     * Decrements a cache item by a specified amount.
123
+     *  
124
+     * @param string $cacheKey
125
+     * @param int $amount
126
+     * @param string $namespace
127
+     * @return bool
128
+     */
129 129
     public function decrement(string $cacheKey, int $amount = 1, string $namespace = '')
130 130
     {
131 131
         return $this->increment($cacheKey, ($amount * -1), $namespace);
132 132
     }
133 133
 
134 134
     /**
135
-    * Store data in the cache permanently.
136
-    *
137
-    * @param string $cacheKey
138
-    * @param mixed $cacheData
139
-    * @return void
140
-    */
135
+     * Store data in the cache permanently.
136
+     *
137
+     * @param string $cacheKey
138
+     * @param mixed $cacheData
139
+     * @return void
140
+     */
141 141
     public function forever(string $cacheKey, mixed $cacheData)
142 142
     {
143 143
         $this->putCache($cacheKey, $cacheData, ttl: 31536000 * 1000);
@@ -145,10 +145,10 @@  discard block
 block discarded – undo
145 145
     }
146 146
 
147 147
     /**
148
-    * Flushes all cache items.
149
-    * 
150
-    * @return void
151
-    */
148
+     * Flushes all cache items.
149
+     * 
150
+     * @return void
151
+     */
152 152
     public function flushCache()
153 153
     {
154 154
         $this->cacheStore->flushCache();
@@ -156,12 +156,12 @@  discard block
 block discarded – undo
156 156
     }
157 157
 
158 158
     /**
159
-    * Retrieves a cache item and deletes it from the cache.
160
-    * 
161
-    * @param string $cacheKey
162
-    * @param string $namespace
163
-    * @return mixed
164
-    */
159
+     * Retrieves a cache item and deletes it from the cache.
160
+     * 
161
+     * @param string $cacheKey
162
+     * @param string $namespace
163
+     * @return mixed
164
+     */
165 165
     public function getAndForget(string $cacheKey, string $namespace = '')
166 166
     {
167 167
         $cachedData = $this->getCache($cacheKey, $namespace);
@@ -176,11 +176,11 @@  discard block
 block discarded – undo
176 176
     }
177 177
 
178 178
     /**
179
-    * Gets all items in a specific namespace.
180
-    * 
181
-    * @param string $namespace
182
-    * @return CacheDataFormatter|array
183
-    */
179
+     * Gets all items in a specific namespace.
180
+     * 
181
+     * @param string $namespace
182
+     * @return CacheDataFormatter|array
183
+     */
184 184
     public function getAll(string $namespace = '')
185 185
     {
186 186
         $cachedData = $this->cacheStore->getAll($namespace);
@@ -196,13 +196,13 @@  discard block
 block discarded – undo
196 196
     }
197 197
 
198 198
     /**
199
-    * Retrieves a single cache item.
200
-    * 
201
-    * @param string $cacheKey
202
-    * @param string $namespace
203
-    * @param string|int $ttl
204
-    * @return CacheDataFormatter|mixed
205
-    */
199
+     * Retrieves a single cache item.
200
+     * 
201
+     * @param string $cacheKey
202
+     * @param string $namespace
203
+     * @param string|int $ttl
204
+     * @return CacheDataFormatter|mixed
205
+     */
206 206
     public function getCache(string $cacheKey, string $namespace = '', string|int $ttl = 3600)
207 207
     {
208 208
         $cacheData = $this->cacheStore->getCache($cacheKey, $namespace, $ttl);
@@ -216,13 +216,13 @@  discard block
 block discarded – undo
216 216
     }
217 217
 
218 218
     /**
219
-    * Retrieves multiple cache items by their keys.
220
-    * 
221
-    * @param array $cacheKeys
222
-    * @param string $namespace
223
-    * @param string|int $ttl
224
-    * @return CacheDataFormatter|array
225
-    */
219
+     * Retrieves multiple cache items by their keys.
220
+     * 
221
+     * @param array $cacheKeys
222
+     * @param string $namespace
223
+     * @param string|int $ttl
224
+     * @return CacheDataFormatter|array
225
+     */
226 226
     public function getMany(array $cacheKeys, string $namespace = '', string|int $ttl = 3600)
227 227
     {
228 228
         $cachedData = $this->cacheStore->getMany($cacheKeys, $namespace, $ttl);
@@ -238,12 +238,12 @@  discard block
 block discarded – undo
238 238
     }
239 239
 
240 240
     /**
241
-    * Checks if a cache item exists.
242
-    * 
243
-    * @param string $cacheKey
244
-    * @param string $namespace
245
-    * @return void
246
-    */
241
+     * Checks if a cache item exists.
242
+     * 
243
+     * @param string $cacheKey
244
+     * @param string $namespace
245
+     * @return void
246
+     */
247 247
     public function has(string $cacheKey, string $namespace = '')
248 248
     {
249 249
         $this->cacheStore->has($cacheKey, $namespace);
@@ -251,13 +251,13 @@  discard block
 block discarded – undo
251 251
     }
252 252
 
253 253
     /**
254
-    * Increments a cache item by a specified amount.
255
-    * 
256
-    * @param string $cacheKey
257
-    * @param int $amount
258
-    * @param string $namespace
259
-    * @return bool
260
-    */
254
+     * Increments a cache item by a specified amount.
255
+     * 
256
+     * @param string $cacheKey
257
+     * @param int $amount
258
+     * @param string $namespace
259
+     * @return bool
260
+     */
261 261
     public function increment(string $cacheKey, int $amount = 1, string $namespace = '')
262 262
     {
263 263
         $cacheData = $this->getCache($cacheKey, $namespace);
@@ -272,24 +272,24 @@  discard block
 block discarded – undo
272 272
     }
273 273
 
274 274
     /**
275
-    * Checks if the last operation was successful.
276
-    * 
277
-    * @return boolean
278
-    */
275
+     * Checks if the last operation was successful.
276
+     * 
277
+     * @return boolean
278
+     */
279 279
     public function isSuccess()
280 280
     {
281 281
         return $this->success;
282 282
     }
283 283
 
284 284
     /**
285
-    * Stores an item in the cache with a specific TTL.
286
-    * 
287
-    * @param string $cacheKey
288
-    * @param mixed  $cacheData
289
-    * @param string $namespace
290
-    * @param string|int $ttl
291
-    * @return void
292
-    */
285
+     * Stores an item in the cache with a specific TTL.
286
+     * 
287
+     * @param string $cacheKey
288
+     * @param mixed  $cacheData
289
+     * @param string $namespace
290
+     * @param string|int $ttl
291
+     * @return void
292
+     */
293 293
     public function putCache(string $cacheKey, mixed $cacheData, string $namespace = '', string|int $ttl = 3600)
294 294
     {
295 295
         $data = CacheerHelper::prepareForStorage($cacheData, $this->compression, $this->encryptionKey);
@@ -298,26 +298,26 @@  discard block
 block discarded – undo
298 298
     }
299 299
 
300 300
     /**
301
-    * Stores multiple items in the cache.
302
-    *  
303
-    * @param array   $items
304
-    * @param string  $namespace
305
-    * @param integer $batchSize
306
-    * @return void
307
-    */
301
+     * Stores multiple items in the cache.
302
+     *  
303
+     * @param array   $items
304
+     * @param string  $namespace
305
+     * @param integer $batchSize
306
+     * @return void
307
+     */
308 308
     public function putMany(array $items, string $namespace = '', int $batchSize = 100)
309 309
     {
310 310
         $this->cacheStore->putMany($items, $namespace, $batchSize);
311 311
     }
312 312
 
313 313
     /**
314
-    * Renews the cache for a specific key with a new TTL.
315
-    * 
316
-    * @param string $cacheKey
317
-    * @param string|int $ttl
318
-    * @param string $namespace
319
-    * @return void
320
-    */
314
+     * Renews the cache for a specific key with a new TTL.
315
+     * 
316
+     * @param string $cacheKey
317
+     * @param string|int $ttl
318
+     * @param string $namespace
319
+     * @return void
320
+     */
321 321
     public function renewCache(string $cacheKey, string|int $ttl = 3600, string $namespace = '')
322 322
     {
323 323
         $this->cacheStore->renewCache($cacheKey, $ttl, $namespace);
@@ -330,13 +330,13 @@  discard block
 block discarded – undo
330 330
     }
331 331
 
332 332
     /**
333
-    * Retrieves a cache item or executes a callback to store it if not found.
334
-    * 
335
-    * @param string $cacheKey
336
-    * @param int|string $ttl
337
-    * @param Closure $callback
338
-    * @return mixed
339
-    */
333
+     * Retrieves a cache item or executes a callback to store it if not found.
334
+     * 
335
+     * @param string $cacheKey
336
+     * @param int|string $ttl
337
+     * @param Closure $callback
338
+     * @return mixed
339
+     */
340 340
     public function remember(string $cacheKey, int|string $ttl, Closure $callback)
341 341
     {
342 342
         $cachedData = $this->getCache($cacheKey, ttl: $ttl);
@@ -353,44 +353,44 @@  discard block
 block discarded – undo
353 353
     }
354 354
 
355 355
     /**
356
-    * Retrieves a cache item or executes a callback to store it permanently if not found.
357
-    * 
358
-    * @param string $cacheKey
359
-    * @param Closure $callback
360
-    * @return mixed
361
-    */
356
+     * Retrieves a cache item or executes a callback to store it permanently if not found.
357
+     * 
358
+     * @param string $cacheKey
359
+     * @param Closure $callback
360
+     * @return mixed
361
+     */
362 362
     public function rememberForever(string $cacheKey, Closure $callback)
363 363
     {
364 364
         return $this->remember($cacheKey, 31536000 * 1000, $callback);
365 365
     }
366 366
 
367 367
     /**
368
-    * Returns a CacheConfig instance for configuration management.
369
-    * 
370
-    * @return CacheConfig
371
-    */
368
+     * Returns a CacheConfig instance for configuration management.
369
+     * 
370
+     * @return CacheConfig
371
+     */
372 372
     public function setConfig()
373 373
     {
374 374
         return new CacheConfig($this);
375 375
     }
376 376
 
377 377
     /**
378
-    * Sets the cache driver based on the configuration.
379
-    * 
380
-    * @return CacheDriver
381
-    */
378
+     * Sets the cache driver based on the configuration.
379
+     * 
380
+     * @return CacheDriver
381
+     */
382 382
     public function setDriver()
383 383
     {
384 384
         return new CacheDriver($this);
385 385
     }
386 386
 
387 387
     /**
388
-    * Sets a message for the cache operation.
389
-    *
390
-    * @param string  $message
391
-    * @param boolean $success
392
-    * @return void
393
-    */
388
+     * Sets a message for the cache operation.
389
+     *
390
+     * @param string  $message
391
+     * @param boolean $success
392
+     * @return void
393
+     */
394 394
     private function setMessage(string $message, bool $success)
395 395
     {
396 396
         $this->message = $message;
@@ -398,42 +398,42 @@  discard block
 block discarded – undo
398 398
     }
399 399
 
400 400
     /**
401
-    * Retrieves the message from the last operation.
402
-    * 
403
-    * @return string
404
-    */
401
+     * Retrieves the message from the last operation.
402
+     * 
403
+     * @return string
404
+     */
405 405
     public function getMessage()
406 406
     {
407 407
         return $this->message;
408 408
     }
409 409
 
410 410
     /**
411
-    * Enables or disables the formatter for cache data.
412
-    * 
413
-    * @return void
414
-    */
411
+     * Enables or disables the formatter for cache data.
412
+     * 
413
+     * @return void
414
+     */
415 415
     public function useFormatter()
416 416
     {
417 417
         $this->formatted = !$this->formatted;
418 418
     }
419 419
 
420 420
     /**
421
-    * Validates the options provided for the Cacheer instance.
422
-    * 
423
-    * @param array $options
424
-    * @return void
425
-    */
421
+     * Validates the options provided for the Cacheer instance.
422
+     * 
423
+     * @param array $options
424
+     * @return void
425
+     */
426 426
     private function validateOptions(array $options)
427 427
     {
428 428
         $this->options = $options;
429 429
     }
430 430
 
431 431
     /**
432
-    * Enable or disable data compression
433
-    *
434
-    * @param bool $status
435
-    * @return $this
436
-    */
432
+     * Enable or disable data compression
433
+     *
434
+     * @param bool $status
435
+     * @return $this
436
+     */
437 437
     public function useCompression(bool $status = true)
438 438
     {
439 439
         $this->compression = $status;
@@ -441,11 +441,11 @@  discard block
 block discarded – undo
441 441
     }
442 442
 
443 443
     /**
444
-    * Enable encryption for cached data
445
-    *
446
-    * @param string $key
447
-    * @return $this
448
-    */
444
+     * Enable encryption for cached data
445
+     *
446
+     * @param string $key
447
+     * @return $this
448
+     */
449 449
     public function useEncryption(string $key)
450 450
     {
451 451
         $this->encryptionKey = $key;
Please login to merge, or discard this patch.
Spacing   +8 added lines, -8 removed lines patch added patch discarded remove patch
@@ -79,7 +79,7 @@  discard block
 block discarded – undo
79 79
     * @param int|string $ttl
80 80
     * @return bool
81 81
     */
82
-    public function add(string $cacheKey, mixed $cacheData, string $namespace = '', int|string $ttl = 3600)
82
+    public function add(string $cacheKey, mixed $cacheData, string $namespace = '', int | string $ttl = 3600)
83 83
     {
84 84
         if (!empty($this->getCache($cacheKey, $namespace))) {
85 85
             return true;
@@ -203,7 +203,7 @@  discard block
 block discarded – undo
203 203
     * @param string|int $ttl
204 204
     * @return CacheDataFormatter|mixed
205 205
     */
206
-    public function getCache(string $cacheKey, string $namespace = '', string|int $ttl = 3600)
206
+    public function getCache(string $cacheKey, string $namespace = '', string | int $ttl = 3600)
207 207
     {
208 208
         $cacheData = $this->cacheStore->getCache($cacheKey, $namespace, $ttl);
209 209
         $this->setMessage($this->cacheStore->getMessage(), $this->cacheStore->isSuccess());
@@ -223,7 +223,7 @@  discard block
 block discarded – undo
223 223
     * @param string|int $ttl
224 224
     * @return CacheDataFormatter|array
225 225
     */
226
-    public function getMany(array $cacheKeys, string $namespace = '', string|int $ttl = 3600)
226
+    public function getMany(array $cacheKeys, string $namespace = '', string | int $ttl = 3600)
227 227
     {
228 228
         $cachedData = $this->cacheStore->getMany($cacheKeys, $namespace, $ttl);
229 229
         $this->setMessage($this->cacheStore->getMessage(), $this->cacheStore->isSuccess());
@@ -262,7 +262,7 @@  discard block
 block discarded – undo
262 262
     {
263 263
         $cacheData = $this->getCache($cacheKey, $namespace);
264 264
 
265
-        if(!empty($cacheData) && is_numeric($cacheData)) {
265
+        if (!empty($cacheData) && is_numeric($cacheData)) {
266 266
             $this->putCache($cacheKey, (int)($cacheData + $amount), $namespace);
267 267
             $this->setMessage($this->getMessage(), $this->isSuccess());
268 268
             return true;
@@ -290,7 +290,7 @@  discard block
 block discarded – undo
290 290
     * @param string|int $ttl
291 291
     * @return void
292 292
     */
293
-    public function putCache(string $cacheKey, mixed $cacheData, string $namespace = '', string|int $ttl = 3600)
293
+    public function putCache(string $cacheKey, mixed $cacheData, string $namespace = '', string | int $ttl = 3600)
294 294
     {
295 295
         $data = CacheerHelper::prepareForStorage($cacheData, $this->compression, $this->encryptionKey);
296 296
         $this->cacheStore->putCache($cacheKey, $data, $namespace, $ttl);
@@ -318,7 +318,7 @@  discard block
 block discarded – undo
318 318
     * @param string $namespace
319 319
     * @return void
320 320
     */
321
-    public function renewCache(string $cacheKey, string|int $ttl = 3600, string $namespace = '')
321
+    public function renewCache(string $cacheKey, string | int $ttl = 3600, string $namespace = '')
322 322
     {
323 323
         $this->cacheStore->renewCache($cacheKey, $ttl, $namespace);
324 324
 
@@ -337,11 +337,11 @@  discard block
 block discarded – undo
337 337
     * @param Closure $callback
338 338
     * @return mixed
339 339
     */
340
-    public function remember(string $cacheKey, int|string $ttl, Closure $callback)
340
+    public function remember(string $cacheKey, int | string $ttl, Closure $callback)
341 341
     {
342 342
         $cachedData = $this->getCache($cacheKey, ttl: $ttl);
343 343
 
344
-        if(!empty($cachedData)) {
344
+        if (!empty($cachedData)) {
345 345
             return $cachedData;
346 346
         }
347 347
 
Please login to merge, or discard this patch.
src/Helpers/CacheFileHelper.php 1 patch
Indentation   +26 added lines, -26 removed lines patch added patch discarded remove patch
@@ -14,11 +14,11 @@  discard block
 block discarded – undo
14 14
 {
15 15
 
16 16
     /**
17
-    * Converts a string expiration format to seconds.
18
-    *
19
-    * @param string $expiration
20
-    * @return int
21
-    */
17
+     * Converts a string expiration format to seconds.
18
+     *
19
+     * @param string $expiration
20
+     * @return int
21
+     */
22 22
     public static function convertExpirationToSeconds(string $expiration)
23 23
     {
24 24
         $units = [
@@ -39,11 +39,11 @@  discard block
 block discarded – undo
39 39
     }
40 40
 
41 41
     /**
42
-    * Merges cache data with existing data.
43
-    * 
44
-    * @param array $options
45
-    * @return array
46
-    */
42
+     * Merges cache data with existing data.
43
+     * 
44
+     * @param array $options
45
+     * @return array
46
+     */
47 47
     public static function mergeCacheData($cacheData)
48 48
     {
49 49
         return CacheerHelper::mergeCacheData($cacheData);
@@ -64,12 +64,12 @@  discard block
 block discarded – undo
64 64
     }
65 65
 
66 66
     /**
67
-    * Calculates the TTL (Time To Live) for cache items.
68
-    *
69
-    * @param string|int $ttl
70
-    * @param int $defaultTTL
71
-    * @return mixed
72
-    */
67
+     * Calculates the TTL (Time To Live) for cache items.
68
+     *
69
+     * @param string|int $ttl
70
+     * @param int $defaultTTL
71
+     * @return mixed
72
+     */
73 73
     public static function ttl($ttl = null, ?int $defaultTTL = null) {
74 74
         if ($ttl) {
75 75
             $ttl = is_string($ttl) ? self::convertExpirationToSeconds($ttl) : $ttl;
@@ -79,15 +79,15 @@  discard block
 block discarded – undo
79 79
         return $ttl;
80 80
     }
81 81
 
82
-  /**
83
-  * Generates an array identifier for cache data.
84
-  * 
85
-  * @param mixed $currentCacheData
86
-  * @param mixed $cacheData
87
-  * @return array
88
-  */
89
-  public static function arrayIdentifier(mixed $currentCacheData, mixed $cacheData)
90
-  {
82
+    /**
83
+     * Generates an array identifier for cache data.
84
+     * 
85
+     * @param mixed $currentCacheData
86
+     * @param mixed $cacheData
87
+     * @return array
88
+     */
89
+    public static function arrayIdentifier(mixed $currentCacheData, mixed $cacheData)
90
+    {
91 91
     return CacheerHelper::arrayIdentifier($currentCacheData, $cacheData);
92
-  }
92
+    }
93 93
 }
Please login to merge, or discard this patch.
src/Helpers/SqliteHelper.php 1 patch
Indentation   +28 added lines, -28 removed lines patch added patch discarded remove patch
@@ -12,24 +12,24 @@  discard block
 block discarded – undo
12 12
 {
13 13
 
14 14
     /**
15
-    * Gets the path to the SQLite database file.
16
-    *  
17
-    * @param string $database
18
-    * @param ?string $path
19
-    * @return string
20
-    */
15
+     * Gets the path to the SQLite database file.
16
+     *  
17
+     * @param string $database
18
+     * @param ?string $path
19
+     * @return string
20
+     */
21 21
     public static function database(string $database = 'database.sqlite', ?string $path = null)
22 22
     {
23 23
         return self::getDynamicSqliteDbPath($database, $path);
24 24
     }
25 25
 
26 26
     /**
27
-    * Gets the path to the SQLite database file dynamically.
28
-    *
29
-    * @param  string $database
30
-    * @param ?string $path
31
-    * @return string
32
-    */
27
+     * Gets the path to the SQLite database file dynamically.
28
+     *
29
+     * @param  string $database
30
+     * @param ?string $path
31
+     * @return string
32
+     */
33 33
     private static function getDynamicSqliteDbPath(string $database, ?string $path = null)
34 34
     {
35 35
         $rootPath = EnvHelper::getRootPath();
@@ -47,11 +47,11 @@  discard block
 block discarded – undo
47 47
     }
48 48
 
49 49
     /**
50
-    * Creates the database directory if it does not exist.
51
-    * 
52
-    * @param string $databaseDir
53
-    * @return void
54
-    */
50
+     * Creates the database directory if it does not exist.
51
+     * 
52
+     * @param string $databaseDir
53
+     * @return void
54
+     */
55 55
     private static function createDatabaseDir(string $databaseDir)
56 56
     {
57 57
         if (!is_dir($databaseDir)) {
@@ -60,11 +60,11 @@  discard block
 block discarded – undo
60 60
     }
61 61
 
62 62
     /**
63
-    * Creates the SQLite database file if it does not exist.
64
-    *
65
-    * @param string $dbFile
66
-    * @return void
67
-    */
63
+     * Creates the SQLite database file if it does not exist.
64
+     *
65
+     * @param string $dbFile
66
+     * @return void
67
+     */
68 68
     private static function createDatabaseFile(string $dbFile)
69 69
     {
70 70
         if (!file_exists($dbFile)) {
@@ -73,12 +73,12 @@  discard block
 block discarded – undo
73 73
     }
74 74
 
75 75
     /**
76
-    * Checks if the database name has the correct extension.
77
-    * If not, appends '.sqlite' to the name.
78
-    *
79
-    * @param string $database
80
-    * @return string
81
-    */
76
+     * Checks if the database name has the correct extension.
77
+     * If not, appends '.sqlite' to the name.
78
+     *
79
+     * @param string $database
80
+     * @return string
81
+     */
82 82
     private static function checkExtension(string $database)
83 83
     {
84 84
         if (strpos($database, '.sqlite') === false) {
Please login to merge, or discard this patch.
src/Utils/CacheLogger.php 1 patch
Indentation   +31 added lines, -31 removed lines patch added patch discarded remove patch
@@ -23,61 +23,61 @@  discard block
 block discarded – undo
23 23
     }
24 24
 
25 25
     /**
26
-    * Logs a info message.
27
-    * 
28
-    * @return void
29
-    */
26
+     * Logs a info message.
27
+     * 
28
+     * @return void
29
+     */
30 30
     public function info($message)
31 31
     {
32 32
         $this->log('INFO', $message);
33 33
     }
34 34
 
35 35
     /**
36
-    * Logs a warning message.
37
-    *
38
-    * @return void
39
-    */
36
+     * Logs a warning message.
37
+     *
38
+     * @return void
39
+     */
40 40
     public function warning($message)
41 41
     {
42 42
         $this->log('WARNING', $message);
43 43
     }
44 44
 
45 45
     /**
46
-    * Logs an error message.
47
-    * 
48
-    * @return void
49
-    */
46
+     * Logs an error message.
47
+     * 
48
+     * @return void
49
+     */
50 50
     public function error($message)
51 51
     {
52 52
         $this->log('ERROR', $message);
53 53
     }
54 54
 
55 55
     /**
56
-    * Logs a debug message.
57
-    * 
58
-    * @return void
59
-    */
56
+     * Logs a debug message.
57
+     * 
58
+     * @return void
59
+     */
60 60
     public function debug($message)
61 61
     {
62 62
         $this->log('DEBUG', $message);
63 63
     }
64 64
 
65 65
     /**
66
-    * Checks if the log level is sufficient to log the message.
67
-    *
68
-    * @param mixed $level
69
-    * @return string|int|false
70
-    */
66
+     * Checks if the log level is sufficient to log the message.
67
+     *
68
+     * @param mixed $level
69
+     * @return string|int|false
70
+     */
71 71
     private function shouldLog(mixed $level)
72 72
     {
73 73
         return array_search($level, $this->logLevels) >= array_search($this->logLevel, $this->logLevels);
74 74
     }
75 75
 
76 76
     /**
77
-    * Rotates the log file if it exceeds the maximum size.
78
-    * 
79
-    * @return void
80
-    */
77
+     * Rotates the log file if it exceeds the maximum size.
78
+     * 
79
+     * @return void
80
+     */
81 81
     private function rotateLog()
82 82
     {
83 83
         if (file_exists($this->logFile) && filesize($this->logFile) >= $this->maxFileSize) {
@@ -87,12 +87,12 @@  discard block
 block discarded – undo
87 87
     }
88 88
 
89 89
     /**
90
-    * Logs a message to the log file.
91
-    * 
92
-    * @param mixed $level
93
-    * @param string $message
94
-    * @return void
95
-    */
90
+     * Logs a message to the log file.
91
+     * 
92
+     * @param mixed $level
93
+     * @param string $message
94
+     * @return void
95
+     */
96 96
     private function log($level, $message)
97 97
     {
98 98
         if (!$this->shouldLog($level)) {
Please login to merge, or discard this patch.
src/Utils/CacheDriver.php 1 patch
Indentation   +31 added lines, -31 removed lines patch added patch discarded remove patch
@@ -20,8 +20,8 @@  discard block
 block discarded – undo
20 20
 {
21 21
 
22 22
     /**
23
-    * @var Cacheer
24
-    */
23
+     * @var Cacheer
24
+     */
25 25
     protected $cacheer;
26 26
 
27 27
     /** @param string $logPath */
@@ -38,10 +38,10 @@  discard block
 block discarded – undo
38 38
     }
39 39
 
40 40
     /**
41
-    * Uses the database driver for caching.
42
-    * 
43
-    * @return Cacheer
44
-    */
41
+     * Uses the database driver for caching.
42
+     * 
43
+     * @return Cacheer
44
+     */
45 45
     public function useDatabaseDriver()
46 46
     {
47 47
         $this->cacheer->cacheStore = new DatabaseCacheStore($this->logPath);
@@ -49,10 +49,10 @@  discard block
 block discarded – undo
49 49
     }
50 50
 
51 51
     /**
52
-    * Uses the file driver for caching.
53
-    *
54
-    * @return Cacheer
55
-    */
52
+     * Uses the file driver for caching.
53
+     *
54
+     * @return Cacheer
55
+     */
56 56
     public function useFileDriver()
57 57
     {
58 58
         $this->cacheer->options['loggerPath'] = $this->logPath;
@@ -61,10 +61,10 @@  discard block
 block discarded – undo
61 61
     }
62 62
 
63 63
     /**
64
-    * Uses the Redis driver for caching.
65
-    * 
66
-    * @return Cacheer
67
-    */
64
+     * Uses the Redis driver for caching.
65
+     * 
66
+     * @return Cacheer
67
+     */
68 68
     public function useRedisDriver()
69 69
     {
70 70
         $this->cacheer->cacheStore = new RedisCacheStore($this->logPath);
@@ -72,10 +72,10 @@  discard block
 block discarded – undo
72 72
     }
73 73
 
74 74
     /**
75
-    * Uses the array driver for caching.
76
-    * 
77
-    * @return Cacheer
78
-    */
75
+     * Uses the array driver for caching.
76
+     * 
77
+     * @return Cacheer
78
+     */
79 79
     public function useArrayDriver()
80 80
     {
81 81
         $this->cacheer->cacheStore = new ArrayCacheStore($this->logPath);
@@ -83,10 +83,10 @@  discard block
 block discarded – undo
83 83
     }
84 84
 
85 85
     /**
86
-    * Uses the default driver for caching.
87
-    * 
88
-    * @return Cacheer
89
-    */
86
+     * Uses the default driver for caching.
87
+     * 
88
+     * @return Cacheer
89
+     */
90 90
     public function useDefaultDriver()
91 91
     {
92 92
         if (!isset($this->cacheer->options['cacheDir'])) {
@@ -103,16 +103,16 @@  discard block
 block discarded – undo
103 103
     }
104 104
 
105 105
     /**
106
-    * Checks if the directory exists or creates it.
107
-    *
108
-    * @param mixed $dirName
109
-    * @return bool
110
-    */
106
+     * Checks if the directory exists or creates it.
107
+     *
108
+     * @param mixed $dirName
109
+     * @return bool
110
+     */
111 111
     private function isDir(mixed $dirName)
112 112
     {
113
-      if (is_dir($dirName)) {
114
-          return true;
115
-      }
116
-      return mkdir($dirName, 0755, true);
113
+        if (is_dir($dirName)) {
114
+            return true;
115
+        }
116
+        return mkdir($dirName, 0755, true);
117 117
     }
118 118
 }
Please login to merge, or discard this patch.