Passed
Branch main (6fd149)
by Sílvio
02:57
created
src/CacheStore/Support/DatabaseTtlResolver.php 1 patch
Spacing   +4 added lines, -4 removed lines patch added patch discarded remove patch
@@ -24,18 +24,18 @@
 block discarded – undo
24 24
      * @param string|int|null $ttl
25 25
      * @return int
26 26
      */
27
-    public function resolve(string|int|null $ttl): int
27
+    public function resolve(string | int | null $ttl): int
28 28
     {
29 29
         $ttlToUse = $ttl;
30 30
 
31
-        if ($this->defaultTTL !== null && ($ttl === null || (int) $ttl === 3600)) {
31
+        if ($this->defaultTTL !== null && ($ttl === null || (int)$ttl === 3600)) {
32 32
             $ttlToUse = $this->defaultTTL;
33 33
         }
34 34
 
35 35
         if (is_string($ttlToUse)) {
36
-            $ttlToUse = (int) CacheFileHelper::convertExpirationToSeconds($ttlToUse);
36
+            $ttlToUse = (int)CacheFileHelper::convertExpirationToSeconds($ttlToUse);
37 37
         }
38 38
 
39
-        return (int) $ttlToUse;
39
+        return (int)$ttlToUse;
40 40
     }
41 41
 }
Please login to merge, or discard this patch.
src/CacheStore/DatabaseCacheStore.php 1 patch
Spacing   +7 added lines, -7 removed lines patch added patch discarded remove patch
@@ -72,7 +72,7 @@  discard block
 block discarded – undo
72 72
 
73 73
         $defaultTTL = null;
74 74
         if (!empty($options['expirationTime'])) {
75
-            $defaultTTL = (int) CacheFileHelper::convertExpirationToSeconds((string) $options['expirationTime']);
75
+            $defaultTTL = (int)CacheFileHelper::convertExpirationToSeconds((string)$options['expirationTime']);
76 76
         }
77 77
 
78 78
         $this->ttlResolver = new DatabaseTtlResolver($defaultTTL);
@@ -80,7 +80,7 @@  discard block
 block discarded – undo
80 80
         $this->tagIndex = new DatabaseCacheTagIndex($this->cacheRepository, $this->status);
81 81
 
82 82
         $lastFlushFile = FlushHelper::pathFor(CacheStoreType::DATABASE, $table);
83
-        $this->flusher = new GenericFlusher($lastFlushFile, function () {
83
+        $this->flusher = new GenericFlusher($lastFlushFile, function() {
84 84
             $this->flushCache();
85 85
         });
86 86
         $this->flusher->handleAutoFlush($options);
@@ -157,7 +157,7 @@  discard block
 block discarded – undo
157 157
      */
158 158
     public function flushTag(string $tag): void
159 159
     {
160
-        $this->tagIndex->flush($tag, function (string $cacheKey, string $namespace): void {
160
+        $this->tagIndex->flush($tag, function(string $cacheKey, string $namespace): void {
161 161
             $this->clearCache($cacheKey, $namespace);
162 162
         });
163 163
     }
@@ -170,7 +170,7 @@  discard block
 block discarded – undo
170 170
      * @param string|int $ttl
171 171
      * @return mixed
172 172
      */
173
-    public function getCache(string $cacheKey, string $namespace = '', string|int $ttl = 3600): mixed
173
+    public function getCache(string $cacheKey, string $namespace = '', string | int $ttl = 3600): mixed
174 174
     {
175 175
         $cacheData = $this->cacheRepository->retrieve($cacheKey, $namespace);
176 176
         if ($cacheData !== null) {
@@ -206,7 +206,7 @@  discard block
 block discarded – undo
206 206
      * @param string|int $ttl
207 207
      * @return array
208 208
      */
209
-    public function getMany(array $cacheKeys, string $namespace = '', string|int $ttl = 3600): array
209
+    public function getMany(array $cacheKeys, string $namespace = '', string | int $ttl = 3600): array
210 210
     {
211 211
         $cacheData = [];
212 212
         foreach ($cacheKeys as $cacheKey) {
@@ -275,7 +275,7 @@  discard block
 block discarded – undo
275 275
     public function putMany(array $items, string $namespace = '', int $batchSize = 100): void
276 276
     {
277 277
         $writer = $batchSize === 100 ? $this->batchWriter : new DatabaseBatchWriter($batchSize);
278
-        $writer->write($items, $namespace, function (string $cacheKey, mixed $cacheData, string $namespace): void {
278
+        $writer->write($items, $namespace, function(string $cacheKey, mixed $cacheData, string $namespace): void {
279 279
             $this->putCache($cacheKey, $cacheData, $namespace);
280 280
         });
281 281
     }
@@ -289,7 +289,7 @@  discard block
 block discarded – undo
289 289
      * @param string|int $ttl
290 290
      * @return bool
291 291
      */
292
-    public function putCache(string $cacheKey, mixed $cacheData, string $namespace = '', string|int $ttl = 3600): bool
292
+    public function putCache(string $cacheKey, mixed $cacheData, string $namespace = '', string | int $ttl = 3600): bool
293 293
     {
294 294
         $ttlToUse = $this->ttlResolver->resolve($ttl);
295 295
         $stored = $this->cacheRepository->store($cacheKey, $cacheData, $namespace, $ttlToUse);
Please login to merge, or discard this patch.
src/CacheStore/ArrayCacheStore.php 1 patch
Spacing   +8 added lines, -8 removed lines patch added patch discarded remove patch
@@ -139,7 +139,7 @@  discard block
 block discarded – undo
139 139
    * @param int|string $ttl
140 140
    * @return mixed
141 141
    */
142
-    public function getCache(string $cacheKey, string $namespace = '', string|int $ttl = 3600): mixed
142
+    public function getCache(string $cacheKey, string $namespace = '', string | int $ttl = 3600): mixed
143 143
     {
144 144
         $arrayStoreKey = $this->keyspace->build($cacheKey, $namespace);
145 145
         $cacheData = $this->arrayStore[$arrayStoreKey] ?? null;
@@ -184,7 +184,7 @@  discard block
 block discarded – undo
184 184
    * @param string|int $ttl
185 185
    * @return array
186 186
    */
187
-    public function getMany(array $cacheKeys, string $namespace = '', string|int $ttl = 3600): array
187
+    public function getMany(array $cacheKeys, string $namespace = '', string | int $ttl = 3600): array
188 188
     {
189 189
         $results = [];
190 190
         foreach ($cacheKeys as $cacheKey) {
@@ -227,7 +227,7 @@  discard block
 block discarded – undo
227 227
         $cacheData = $this->getCache($cacheKey, $namespace);
228 228
 
229 229
         if (!empty($cacheData) && is_numeric($cacheData)) {
230
-            $this->putCache($cacheKey, (int) ($cacheData + $amount), $namespace);
230
+            $this->putCache($cacheKey, (int)($cacheData + $amount), $namespace);
231 231
             return true;
232 232
         }
233 233
 
@@ -263,7 +263,7 @@  discard block
 block discarded – undo
263 263
    * @param int|string $ttl
264 264
    * @return bool
265 265
    */
266
-    public function putCache(string $cacheKey, mixed $cacheData, string $namespace = '', int|string $ttl = 3600): bool
266
+    public function putCache(string $cacheKey, mixed $cacheData, string $namespace = '', int | string $ttl = 3600): bool
267 267
     {
268 268
         $arrayStoreKey = $this->keyspace->build($cacheKey, $namespace);
269 269
 
@@ -287,7 +287,7 @@  discard block
 block discarded – undo
287 287
     public function putMany(array $items, string $namespace = '', int $batchSize = 100): void
288 288
     {
289 289
         $writer = new ArrayCacheBatchWriter($batchSize);
290
-        $writer->write($items, $namespace, function (string $cacheKey, mixed $cacheData, string $namespace): void {
290
+        $writer->write($items, $namespace, function(string $cacheKey, mixed $cacheData, string $namespace): void {
291 291
             $this->putCache($cacheKey, $cacheData, $namespace);
292 292
         });
293 293
 
@@ -302,12 +302,12 @@  discard block
 block discarded – undo
302 302
    * @param string $namespace
303 303
    * @return void
304 304
    */
305
-    public function renewCache(string $cacheKey, int|string $ttl = 3600, string $namespace = ''): void
305
+    public function renewCache(string $cacheKey, int | string $ttl = 3600, string $namespace = ''): void
306 306
     {
307 307
         $arrayStoreKey = $this->keyspace->build($cacheKey, $namespace);
308 308
 
309 309
         if (isset($this->arrayStore[$arrayStoreKey])) {
310
-            $ttlSeconds = is_numeric($ttl) ? (int) $ttl : strtotime($ttl) - time();
310
+            $ttlSeconds = is_numeric($ttl) ? (int)$ttl : strtotime($ttl) - time();
311 311
             $this->arrayStore[$arrayStoreKey]['expirationTime'] = time() + $ttlSeconds;
312 312
             $this->status->record("cacheKey: {$cacheKey} renewed successfully", true);
313 313
         }
@@ -333,7 +333,7 @@  discard block
 block discarded – undo
333 333
    */
334 334
     public function flushTag(string $tag): void
335 335
     {
336
-        $this->tagIndex->flush($tag, function (string $cacheKey, string $namespace): void {
336
+        $this->tagIndex->flush($tag, function(string $cacheKey, string $namespace): void {
337 337
             $this->clearCache($cacheKey, $namespace);
338 338
         });
339 339
     }
Please login to merge, or discard this patch.
src/CacheStore/FileCacheStore.php 1 patch
Spacing   +6 added lines, -6 removed lines patch added patch discarded remove patch
@@ -78,7 +78,7 @@  discard block
 block discarded – undo
78 78
         $this->flusher = new FileCacheFlusher($this->fileManager, $this->cacheDir);
79 79
         $this->tagIndex = new FileCacheTagIndex($this->fileManager, $this->cacheDir, $this->status);
80 80
         if (isset($options['expirationTime'])) {
81
-            $this->defaultTTL = (int) CacheFileHelper::convertExpirationToSeconds((string) $options['expirationTime']);
81
+            $this->defaultTTL = (int)CacheFileHelper::convertExpirationToSeconds((string)$options['expirationTime']);
82 82
         }
83 83
         $this->flusher->handleAutoFlush($options);
84 84
     }
@@ -162,7 +162,7 @@  discard block
 block discarded – undo
162 162
      */
163 163
     public function flushTag(string $tag): void
164 164
     {
165
-        $this->tagIndex->flush($tag, function (string $cacheKey, string $namespace): void {
165
+        $this->tagIndex->flush($tag, function(string $cacheKey, string $namespace): void {
166 166
             $this->clearCache($cacheKey, $namespace);
167 167
         });
168 168
     }
@@ -186,7 +186,7 @@  discard block
 block discarded – undo
186 186
      * @return mixed
187 187
      * @throws CacheFileException
188 188
      */
189
-    public function getCache(string $cacheKey, string $namespace = '', string|int $ttl = 3600): mixed
189
+    public function getCache(string $cacheKey, string $namespace = '', string | int $ttl = 3600): mixed
190 190
     {
191 191
         $ttlSeconds = CacheFileHelper::ttl($ttl, $this->defaultTTL);
192 192
         $cacheFile = $this->pathBuilder->build($cacheKey, $namespace);
@@ -246,7 +246,7 @@  discard block
 block discarded – undo
246 246
      * @return array
247 247
      * @throws CacheFileException
248 248
      */
249
-    public function getMany(array $cacheKeys, string $namespace = '', string|int $ttl = 3600): array
249
+    public function getMany(array $cacheKeys, string $namespace = '', string | int $ttl = 3600): array
250 250
     {
251 251
         $ttl = CacheFileHelper::ttl($ttl, $this->defaultTTL);
252 252
         $results = [];
@@ -286,7 +286,7 @@  discard block
 block discarded – undo
286 286
      * @return bool
287 287
      * @throws CacheFileException
288 288
      */
289
-    public function putCache(string $cacheKey, mixed $cacheData, string $namespace = '', string|int $ttl = 3600): bool
289
+    public function putCache(string $cacheKey, mixed $cacheData, string $namespace = '', string | int $ttl = 3600): bool
290 290
     {
291 291
         $cacheFile = $this->pathBuilder->build($cacheKey, $namespace);
292 292
         $data = $this->fileManager->serialize($cacheData);
@@ -326,7 +326,7 @@  discard block
 block discarded – undo
326 326
      * @return void
327 327
      * @throws CacheFileException
328 328
      */
329
-    public function renewCache(string $cacheKey, string|int $ttl, string $namespace = ''): void
329
+    public function renewCache(string $cacheKey, string | int $ttl, string $namespace = ''): void
330 330
     {
331 331
         $cacheData = $this->getCache($cacheKey, $namespace);
332 332
         if ($cacheData !== null) {
Please login to merge, or discard this patch.