Passed
Pull Request — main (#61)
by Sílvio
02:54
created
src/CacheStore/RedisCacheStore.php 1 patch
Spacing   +10 added lines, -10 removed lines patch added patch discarded remove patch
@@ -61,17 +61,17 @@  discard block
 block discarded – undo
61 61
         
62 62
         // OptionBuilder support
63 63
         if (!empty($options['namespace'])) {
64
-            $this->namespace = (string) $options['namespace'];
64
+            $this->namespace = (string)$options['namespace'];
65 65
         }
66 66
 
67 67
         // Default TTL from options
68 68
         if (!empty($options['expirationTime'])) {
69
-            $this->defaultTTL = (int) CacheFileHelper::convertExpirationToSeconds((string) $options['expirationTime']);
69
+            $this->defaultTTL = (int)CacheFileHelper::convertExpirationToSeconds((string)$options['expirationTime']);
70 70
         }
71 71
 
72 72
         // Auto-flush support
73 73
         $lastFlushFile = FlushHelper::pathFor('redis', $this->namespace ?: 'default');
74
-        $this->flusher = new GenericFlusher($lastFlushFile, function () {
74
+        $this->flusher = new GenericFlusher($lastFlushFile, function() {
75 75
             $this->flushCache();
76 76
         });
77 77
         $this->flusher->handleAutoFlush($options);
@@ -159,7 +159,7 @@  discard block
 block discarded – undo
159 159
      * @param string|int $ttl
160 160
      * @return mixed
161 161
      */
162
-    public function getCache(string $cacheKey, string $namespace = '', string|int $ttl = 3600): mixed
162
+    public function getCache(string $cacheKey, string $namespace = '', string | int $ttl = 3600): mixed
163 163
     {
164 164
         $fullCacheKey = $this->buildKey($cacheKey, $namespace);
165 165
         $cacheData = $this->redis->get($fullCacheKey);
@@ -214,7 +214,7 @@  discard block
 block discarded – undo
214 214
      * @param string|int $ttl
215 215
      * @return array
216 216
      */
217
-    public function getMany(array $cacheKeys, string $namespace = '', string|int $ttl = 3600): array
217
+    public function getMany(array $cacheKeys, string $namespace = '', string | int $ttl = 3600): array
218 218
     {
219 219
         $results = [];
220 220
         foreach ($cacheKeys as $cacheKey) {
@@ -314,7 +314,7 @@  discard block
 block discarded – undo
314 314
      * @param string|int|null $ttl
315 315
      * @return Status|null
316 316
      */
317
-    public function putCache(string $cacheKey, mixed $cacheData, string $namespace = '', string|int|null $ttl = null): ?Status
317
+    public function putCache(string $cacheKey, mixed $cacheData, string $namespace = '', string | int | null $ttl = null): ?Status
318 318
     {
319 319
         $cacheFullKey = $this->buildKey($cacheKey, $namespace);
320 320
         $serializedData = CacheRedisHelper::serialize($cacheData);
@@ -325,10 +325,10 @@  discard block
 block discarded – undo
325 325
             $ttlToUse = $this->defaultTTL;
326 326
         }
327 327
         if (is_string($ttlToUse)) {
328
-            $ttlToUse = (int) CacheFileHelper::convertExpirationToSeconds($ttlToUse);
328
+            $ttlToUse = (int)CacheFileHelper::convertExpirationToSeconds($ttlToUse);
329 329
         }
330 330
 
331
-        $result = $ttlToUse ? $this->redis->setex($cacheFullKey, (int) $ttlToUse, $serializedData)
331
+        $result = $ttlToUse ? $this->redis->setex($cacheFullKey, (int)$ttlToUse, $serializedData)
332 332
                             : $this->redis->set($cacheFullKey, $serializedData);
333 333
 
334 334
         if ($result) {
@@ -370,7 +370,7 @@  discard block
 block discarded – undo
370 370
      * @return void
371 371
      * @throws CacheRedisException
372 372
      */
373
-    public function renewCache(string $cacheKey, string|int $ttl, string $namespace = ''): void
373
+    public function renewCache(string $cacheKey, string | int $ttl, string $namespace = ''): void
374 374
     {
375 375
         $cacheFullKey = $this->buildKey($cacheKey, $namespace);
376 376
         $dump = $this->getDump($cacheFullKey);
@@ -401,7 +401,7 @@  discard block
 block discarded – undo
401 401
      * @return bool
402 402
      * @throws CacheRedisException
403 403
      */
404
-    private function restoreKey(string $fullKey, string|int $ttl, mixed $dump): bool
404
+    private function restoreKey(string $fullKey, string | int $ttl, mixed $dump): bool
405 405
     {
406 406
         try {
407 407
             $this->redis->restore($fullKey, $ttl * 1000, $dump, 'REPLACE');
Please login to merge, or discard this patch.
src/CacheStore/DatabaseCacheStore.php 1 patch
Spacing   +14 added lines, -14 removed lines patch added patch discarded remove patch
@@ -56,11 +56,11 @@  discard block
 block discarded – undo
56 56
         $this->cacheRepository = new CacheDatabaseRepository($table);
57 57
 
58 58
         if (!empty($options['expirationTime'])) {
59
-            $this->defaultTTL = (int) CacheFileHelper::convertExpirationToSeconds((string) $options['expirationTime']);
59
+            $this->defaultTTL = (int)CacheFileHelper::convertExpirationToSeconds((string)$options['expirationTime']);
60 60
         }
61 61
 
62 62
         $lastFlushFile = FlushHelper::pathFor('db', $table);
63
-        $this->flusher = new GenericFlusher($lastFlushFile, function () {
63
+        $this->flusher = new GenericFlusher($lastFlushFile, function() {
64 64
             $this->flushCache();
65 65
         });
66 66
         $this->flusher->handleAutoFlush($options);
@@ -98,7 +98,7 @@  discard block
 block discarded – undo
98 98
     public function clearCache(string $cacheKey, string $namespace = ''): void
99 99
     {
100 100
         $data = $this->cacheRepository->clear($cacheKey, $namespace);
101
-        if($data) {
101
+        if ($data) {
102 102
             $this->setMessage("Cache deleted successfully!", true);
103 103
         } else {
104 104
             $this->setMessage("Cache does not exists!", false);
@@ -114,7 +114,7 @@  discard block
 block discarded – undo
114 114
      */
115 115
     public function flushCache(): void
116 116
     {
117
-        if($this->cacheRepository->flush()){
117
+        if ($this->cacheRepository->flush()) {
118 118
             $this->setMessage("Flush finished successfully", true);
119 119
         } else {
120 120
             $this->setMessage("Something went wrong. Please, try again.", false);
@@ -132,7 +132,7 @@  discard block
 block discarded – undo
132 132
      * @param string|int $ttl
133 133
      * @return mixed
134 134
      */
135
-    public function getCache(string $cacheKey, string $namespace = '', string|int $ttl = 3600): mixed
135
+    public function getCache(string $cacheKey, string $namespace = '', string | int $ttl = 3600): mixed
136 136
     {
137 137
         $cacheData = $this->retrieveCache($cacheKey, $namespace);
138 138
         if ($cacheData) {
@@ -172,7 +172,7 @@  discard block
 block discarded – undo
172 172
      * @param string|int $ttl
173 173
      * @return array
174 174
      */
175
-    public function getMany(array $cacheKeys, string $namespace = '', string|int $ttl = 3600): array
175
+    public function getMany(array $cacheKeys, string $namespace = '', string | int $ttl = 3600): array
176 176
     {
177 177
         $cacheData = [];
178 178
         foreach ($cacheKeys as $cacheKey) {
@@ -262,17 +262,17 @@  discard block
 block discarded – undo
262 262
      * @param string|int $ttl
263 263
      * @return bool
264 264
      */
265
-    public function putCache(string $cacheKey, mixed $cacheData, string $namespace = '', string|int $ttl = 3600): bool
265
+    public function putCache(string $cacheKey, mixed $cacheData, string $namespace = '', string | int $ttl = 3600): bool
266 266
     {
267 267
         $ttlToUse = $ttl;
268 268
         if ($this->defaultTTL !== null && ($ttl === null || (int)$ttl === 3600)) {
269 269
             $ttlToUse = $this->defaultTTL;
270 270
         }
271 271
         if (is_string($ttlToUse)) {
272
-            $ttlToUse = (int) CacheFileHelper::convertExpirationToSeconds($ttlToUse);
272
+            $ttlToUse = (int)CacheFileHelper::convertExpirationToSeconds($ttlToUse);
273 273
         }
274 274
 
275
-        if($this->storeCache($cacheKey, $cacheData, $namespace, $ttlToUse)){
275
+        if ($this->storeCache($cacheKey, $cacheData, $namespace, $ttlToUse)) {
276 276
             $this->logger->debug("{$this->getMessage()} from database driver.");
277 277
             return true;
278 278
         }
@@ -307,7 +307,7 @@  discard block
 block discarded – undo
307 307
      */
308 308
     private function processBatchItems(array $batchItems, string $namespace): void
309 309
     {
310
-        foreach($batchItems as $item) {
310
+        foreach ($batchItems as $item) {
311 311
             CacheDatabaseHelper::validateCacheItem($item);
312 312
             $cacheKey = $item['cacheKey'];
313 313
             $cacheData = $item['cacheData'];
@@ -324,7 +324,7 @@  discard block
 block discarded – undo
324 324
      * @param string $namespace
325 325
      * @return bool
326 326
      */
327
-    private function renew(string $cacheKey, string|int $ttl = 3600, string $namespace = ''): bool
327
+    private function renew(string $cacheKey, string | int $ttl = 3600, string $namespace = ''): bool
328 328
     {
329 329
         $cacheData = $this->getCache($cacheKey, $namespace);
330 330
         if ($cacheData) {
@@ -372,10 +372,10 @@  discard block
 block discarded – undo
372 372
      * @param string|int $ttl
373 373
      * @return bool
374 374
      */
375
-    private function storeCache(string $cacheKey, mixed $cacheData, string $namespace = '', string|int $ttl = 3600): bool
375
+    private function storeCache(string $cacheKey, mixed $cacheData, string $namespace = '', string | int $ttl = 3600): bool
376 376
     {
377 377
         $data = $this->cacheRepository->store($cacheKey, $cacheData, $namespace, $ttl);
378
-        if($data) {
378
+        if ($data) {
379 379
             $this->setMessage("Cache Stored Successfully", true);
380 380
             return true;
381 381
         }
@@ -394,7 +394,7 @@  discard block
 block discarded – undo
394 394
     private function updateCache(string $cacheKey, mixed $cacheData, string $namespace = ''): bool
395 395
     {
396 396
         $data = $this->cacheRepository->update($cacheKey, $cacheData, $namespace);
397
-        if($data) {
397
+        if ($data) {
398 398
             $this->setMessage("Cache updated successfully.", true);
399 399
             return true;
400 400
         }
Please login to merge, or discard this patch.
src/Support/TimeBuilder.php 1 patch
Indentation   +36 added lines, -36 removed lines patch added patch discarded remove patch
@@ -12,24 +12,24 @@  discard block
 block discarded – undo
12 12
 class TimeBuilder
13 13
 {
14 14
     
15
-  /** @param Closure $callback */
16
-  private Closure $callback;
15
+    /** @param Closure $callback */
16
+    private Closure $callback;
17 17
 
18
-  /** @var mixed */
19
-  private $builder = null;
18
+    /** @var mixed */
19
+    private $builder = null;
20 20
 
21
-  /**
22
-  * TimeBuilder constructor.
23
-  * @param Closure $callback
24
-  * @param mixed $builder
25
-  *
26
-  * @return void
27
-  */
28
-  public function __construct(Closure $callback, $builder)
29
-  {
21
+    /**
22
+     * TimeBuilder constructor.
23
+     * @param Closure $callback
24
+     * @param mixed $builder
25
+     *
26
+     * @return void
27
+     */
28
+    public function __construct(Closure $callback, $builder)
29
+    {
30 30
     $this->callback = $callback;
31 31
     $this->builder = $builder;
32
-  }
32
+    }
33 33
 
34 34
     /**
35 35
      * Sets the time in seconds.
@@ -37,10 +37,10 @@  discard block
 block discarded – undo
37 37
      * @param int $seconds
38 38
      * @return mixed
39 39
      */
40
-  public function second(int $seconds)
41
-  {
40
+    public function second(int $seconds)
41
+    {
42 42
     return $this->setTime($seconds, "seconds");
43
-  }
43
+    }
44 44
 
45 45
     /**
46 46
      * Sets the time in minutes.
@@ -48,10 +48,10 @@  discard block
 block discarded – undo
48 48
      * @param int $minutes
49 49
      * @return mixed
50 50
      */
51
-  public function minute(int $minutes)
52
-  {
51
+    public function minute(int $minutes)
52
+    {
53 53
     return $this->setTime($minutes, "minutes");
54
-  }
54
+    }
55 55
 
56 56
     /**
57 57
      * Sets the time in hours.
@@ -59,10 +59,10 @@  discard block
 block discarded – undo
59 59
      * @param int $hours
60 60
      * @return mixed
61 61
      */
62
-  public function hour(int $hours)
63
-  {
62
+    public function hour(int $hours)
63
+    {
64 64
     return $this->setTime($hours, "hours");
65
-  }
65
+    }
66 66
 
67 67
     /**
68 68
      * Sets the time in days.
@@ -70,10 +70,10 @@  discard block
 block discarded – undo
70 70
      * @param int $days
71 71
      * @return mixed
72 72
      */
73
-  public function day(int $days)
74
-  {
73
+    public function day(int $days)
74
+    {
75 75
     return $this->setTime($days, "days");
76
-  }
76
+    }
77 77
 
78 78
     /**
79 79
      * Sets the time in weeks.
@@ -81,10 +81,10 @@  discard block
 block discarded – undo
81 81
      * @param int $weeks
82 82
      * @return mixed
83 83
      */
84
-  public function week(int $weeks)
85
-  {
84
+    public function week(int $weeks)
85
+    {
86 86
     return $this->setTime($weeks, "weeks");
87
-  }
87
+    }
88 88
 
89 89
     /**
90 90
      * Sets the time in months.
@@ -92,10 +92,10 @@  discard block
 block discarded – undo
92 92
      * @param int $months
93 93
      * @return mixed
94 94
      */
95
-  public function month(int $months)
96
-  {
95
+    public function month(int $months)
96
+    {
97 97
     return $this->setTime($months, "months");
98
-  }
98
+    }
99 99
 
100 100
 
101 101
     /**
@@ -105,10 +105,10 @@  discard block
 block discarded – undo
105 105
      * @param string $unit
106 106
      * @return mixed
107 107
      */
108
-  private function setTime(int $value, string $unit)
109
-  {
110
-   ($this->callback)("{$value} {$unit}");
108
+    private function setTime(int $value, string $unit)
109
+    {
110
+    ($this->callback)("{$value} {$unit}");
111 111
     return $this->builder;
112
-  }
112
+    }
113 113
 
114 114
 }
Please login to merge, or discard this patch.