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