Passed
Push — main ( 994ffc...08f4bd )
by Sílvio
01:02 queued 14s
created
src/CacheStore/CacheManager/FileCacheManager.php 1 patch
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -91,7 +91,7 @@
 block discarded – undo
91 91
     */
92 92
     public function serialize(mixed $data, bool $serialize = true)
93 93
     {
94
-        if($serialize) {
94
+        if ($serialize) {
95 95
             return serialize($data);
96 96
         }
97 97
         return unserialize($data);
Please login to merge, or discard this patch.
src/CacheStore/RedisCacheStore.php 1 patch
Spacing   +6 added lines, -6 removed lines patch added patch discarded remove patch
@@ -118,7 +118,7 @@  discard block
 block discarded – undo
118 118
      * @param string|int $ttl
119 119
      * @return mixed
120 120
      */
121
-    public function getCache(string $cacheKey, string $namespace = '', string|int $ttl = 3600)
121
+    public function getCache(string $cacheKey, string $namespace = '', string | int $ttl = 3600)
122 122
     {
123 123
         $fullCacheKey = $this->buildKey($cacheKey, $namespace);
124 124
         $cacheData = $this->redis->get($fullCacheKey);
@@ -139,7 +139,7 @@  discard block
 block discarded – undo
139 139
      * @param string|int $ttl
140 140
      * @return array
141 141
      */
142
-    public function getMany(array $cacheKeys, string $namespace = '', string|int $ttl = 3600)
142
+    public function getMany(array $cacheKeys, string $namespace = '', string | int $ttl = 3600)
143 143
     {
144 144
         $results = [];
145 145
         foreach ($cacheKeys as $cacheKey) {
@@ -227,12 +227,12 @@  discard block
 block discarded – undo
227 227
      * @param string|int|null $ttl
228 228
      * @return mixed
229 229
      */
230
-    public function putCache(string $cacheKey, mixed $cacheData, string $namespace = '', string|int|null $ttl = null)
230
+    public function putCache(string $cacheKey, mixed $cacheData, string $namespace = '', string | int | null $ttl = null)
231 231
     {
232 232
         $cacheFullKey = $this->buildKey($cacheKey, $namespace);
233 233
         $serializedData = CacheRedisHelper::serialize($cacheData);
234 234
 
235
-        $result = $ttl ? $this->redis->setex($cacheFullKey, (int) $ttl, $serializedData)
235
+        $result = $ttl ? $this->redis->setex($cacheFullKey, (int)$ttl, $serializedData)
236 236
                        : $this->redis->set($cacheFullKey, $serializedData);
237 237
 
238 238
         if ($result) {
@@ -269,7 +269,7 @@  discard block
 block discarded – undo
269 269
      * @param string $namespace
270 270
      * @return void
271 271
      */
272
-    public function renewCache(string $cacheKey, string|int $ttl, string $namespace = '')
272
+    public function renewCache(string $cacheKey, string | int $ttl, string $namespace = '')
273 273
     {
274 274
         $cacheFullKey = $this->buildKey($cacheKey, $namespace);
275 275
         $dump = $this->getDump($cacheFullKey);
@@ -297,7 +297,7 @@  discard block
 block discarded – undo
297 297
      * @param mixed $dump
298 298
      * @return bool
299 299
      */
300
-    private function restoreKey(string $fullKey, string|int $ttl, mixed $dump)
300
+    private function restoreKey(string $fullKey, string | int $ttl, mixed $dump)
301 301
     {
302 302
         try {
303 303
             $this->redis->restore($fullKey, $ttl * 1000, $dump, 'REPLACE');
Please login to merge, or discard this patch.
src/CacheStore/DatabaseCacheStore.php 1 patch
Spacing   +11 added lines, -11 removed lines patch added patch discarded remove patch
@@ -68,7 +68,7 @@  discard block
 block discarded – undo
68 68
     public function clearCache(string $cacheKey, string $namespace = '')
69 69
     {
70 70
         $data = $this->cacheRepository->clear($cacheKey, $namespace);
71
-        if($data) {
71
+        if ($data) {
72 72
             $this->setMessage("Cache deleted successfully!", true);
73 73
         } else {
74 74
             $this->setMessage("Cache does not exists!", false);
@@ -82,7 +82,7 @@  discard block
 block discarded – undo
82 82
      */
83 83
     public function flushCache()
84 84
     {
85
-        if($this->cacheRepository->flush()){
85
+        if ($this->cacheRepository->flush()) {
86 86
             $this->setMessage("Flush finished successfully", true);
87 87
         } else {
88 88
             $this->setMessage("Something went wrong. Please, try again.", false);
@@ -98,7 +98,7 @@  discard block
 block discarded – undo
98 98
      * @param string|int $ttl
99 99
      * @return mixed
100 100
      */
101
-    public function getCache(string $cacheKey, string $namespace = '', string|int $ttl = 3600)
101
+    public function getCache(string $cacheKey, string $namespace = '', string | int $ttl = 3600)
102 102
     {
103 103
         $cacheData = $this->retrieveCache($cacheKey, $namespace);
104 104
         if ($cacheData) {
@@ -117,7 +117,7 @@  discard block
 block discarded – undo
117 117
      * @param string|int $ttl
118 118
      * @return array
119 119
      */
120
-    public function getMany(array $cacheKeys, string $namespace = '', string|int $ttl = 3600)
120
+    public function getMany(array $cacheKeys, string $namespace = '', string | int $ttl = 3600)
121 121
     {
122 122
         $cacheData = [];
123 123
         foreach ($cacheKeys as $cacheKey) {
@@ -190,9 +190,9 @@  discard block
 block discarded – undo
190 190
      * @param string|int $ttl
191 191
      * @return bool
192 192
      */
193
-    public function putCache(string $cacheKey, mixed $cacheData, string $namespace = '', string|int $ttl = 3600)
193
+    public function putCache(string $cacheKey, mixed $cacheData, string $namespace = '', string | int $ttl = 3600)
194 194
     {
195
-        if($this->storeCache($cacheKey, $cacheData, $namespace, $ttl)){
195
+        if ($this->storeCache($cacheKey, $cacheData, $namespace, $ttl)) {
196 196
             $this->logger->debug("{$this->getMessage()} from database driver.");
197 197
             return true;
198 198
         }
@@ -223,7 +223,7 @@  discard block
 block discarded – undo
223 223
      */
224 224
     private function processBatchItems(array $batchItems, string $namespace)
225 225
     {
226
-        foreach($batchItems as $item) {
226
+        foreach ($batchItems as $item) {
227 227
             CacheDatabaseHelper::validateCacheItem($item);
228 228
             $cacheKey = $item['cacheKey'];
229 229
             $cacheData = $item['cacheData'];
@@ -238,7 +238,7 @@  discard block
 block discarded – undo
238 238
      * @param string $namespace
239 239
      * @return bool
240 240
      */
241
-    private function renew(string $cacheKey, string|int $ttl = 3600, string $namespace = '')
241
+    private function renew(string $cacheKey, string | int $ttl = 3600, string $namespace = '')
242 242
     {
243 243
         $cacheData = $this->getCache($cacheKey, $namespace);
244 244
         if ($cacheData) {
@@ -281,10 +281,10 @@  discard block
 block discarded – undo
281 281
      * @param integer $ttl
282 282
      * @return bool
283 283
      */
284
-    private function storeCache(string $cacheKey, mixed $cacheData, string $namespace = '', string|int $ttl = 3600)
284
+    private function storeCache(string $cacheKey, mixed $cacheData, string $namespace = '', string | int $ttl = 3600)
285 285
     {
286 286
         $data = $this->cacheRepository->store($cacheKey, $cacheData, $namespace, $ttl);
287
-        if($data) {
287
+        if ($data) {
288 288
             $this->setMessage("Cache Stored Successfully", true);
289 289
             return true;
290 290
         }
@@ -301,7 +301,7 @@  discard block
 block discarded – undo
301 301
     private function updateCache(string $cacheKey, mixed $cacheData, string $namespace = '')
302 302
     {
303 303
         $data = $this->cacheRepository->update($cacheKey, $cacheData, $namespace);
304
-        if($data) {
304
+        if ($data) {
305 305
             $this->setMessage("Cache updated successfully.", true);
306 306
             return true;
307 307
         }
Please login to merge, or discard this patch.
src/CacheStore/ArrayCacheStore.php 1 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/CacheStore/CacheManager/FileCacheFlusher.php 1 patch
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -52,7 +52,7 @@
 block discarded – undo
52 52
             return;
53 53
         }
54 54
 
55
-        $lastFlushTime = (int) $this->fileManager->readFile($this->lastFlushTimeFile);
55
+        $lastFlushTime = (int)$this->fileManager->readFile($this->lastFlushTimeFile);
56 56
 
57 57
         if ((time() - $lastFlushTime) >= $flushAfterSeconds) {
58 58
             $this->flushCache();
Please login to merge, or discard this patch.
src/Interface/CacheerInterface.php 1 patch
Spacing   +3 added lines, -3 removed lines patch added patch discarded remove patch
@@ -52,7 +52,7 @@  discard block
 block discarded – undo
52 52
      * @param string|int $ttl Lifetime in seconds (default: 3600)
53 53
      * @return mixed Returns the cached data or null if not found
54 54
      */
55
-    public function getCache(string $cacheKey, string $namespace = '', string|int $ttl = 3600);
55
+    public function getCache(string $cacheKey, string $namespace = '', string | int $ttl = 3600);
56 56
 
57 57
     /**
58 58
      * Retrieves multiple cache items by their keys.
@@ -62,7 +62,7 @@  discard block
 block discarded – undo
62 62
      * @param string|int $ttl Lifetime in seconds (default: 3600)
63 63
      * @return CacheDataFormatter|mixed Returns a formatter with the retrieved items
64 64
      */
65
-    public function getMany(array $cacheKeys, string $namespace, string|int $ttl = 3600);
65
+    public function getMany(array $cacheKeys, string $namespace, string | int $ttl = 3600);
66 66
 
67 67
     /**
68 68
      * Checks if a cache item exists.
@@ -82,7 +82,7 @@  discard block
 block discarded – undo
82 82
      * @param string|int $ttl Lifetime in seconds (default: 3600)
83 83
      * @return bool True on success, false on failure
84 84
      */
85
-    public function putCache(string $cacheKey, mixed $cacheData, string $namespace = '', int|string $ttl = 3600);
85
+    public function putCache(string $cacheKey, mixed $cacheData, string $namespace = '', int | string $ttl = 3600);
86 86
 
87 87
     /**
88 88
      * Stores multiple items in the cache.
Please login to merge, or discard this patch.
src/CacheStore/FileCacheStore.php 1 patch
Spacing   +4 added lines, -4 removed lines patch added patch discarded remove patch
@@ -178,7 +178,7 @@  discard block
 block discarded – undo
178 178
      * @param string|int $ttl
179 179
      * @return string
180 180
      */
181
-    public function getCache(string $cacheKey, string $namespace = '', string|int $ttl = 3600)
181
+    public function getCache(string $cacheKey, string $namespace = '', string | int $ttl = 3600)
182 182
     {
183 183
        
184 184
         $ttl = CacheFileHelper::ttl($ttl, $this->defaultTTL);
@@ -263,7 +263,7 @@  discard block
 block discarded – undo
263 263
      * @param string|int $ttl
264 264
      * @return mixed
265 265
      */
266
-    public function getMany(array $cacheKeys, string $namespace = '', string|int $ttl = 3600)
266
+    public function getMany(array $cacheKeys, string $namespace = '', string | int $ttl = 3600)
267 267
     {
268 268
         $ttl = CacheFileHelper::ttl($ttl, $this->defaultTTL);
269 269
         $results = [];
@@ -309,7 +309,7 @@  discard block
 block discarded – undo
309 309
      * @param string|int $ttl
310 310
      * @return void
311 311
      */
312
-    public function putCache(string $cacheKey, mixed $cacheData, string $namespace = '', string|int $ttl = 3600)
312
+    public function putCache(string $cacheKey, mixed $cacheData, string $namespace = '', string | int $ttl = 3600)
313 313
     {
314 314
         $cacheFile = $this->buildCacheFilePath($cacheKey, $namespace);
315 315
         $data = $this->fileManager->serialize($cacheData);
@@ -346,7 +346,7 @@  discard block
 block discarded – undo
346 346
      * @param string $namespace
347 347
      * @return void
348 348
      */
349
-    public function renewCache(string $cacheKey, string|int $ttl, string $namespace = '')
349
+    public function renewCache(string $cacheKey, string | int $ttl, string $namespace = '')
350 350
     {
351 351
         $cacheData = $this->getCache($cacheKey, $namespace);
352 352
         if ($cacheData) {
Please login to merge, or discard this patch.
tests/Feature/FileCacheStoreFeatureTest.php 1 patch
Spacing   +4 added lines, -4 removed lines patch added patch discarded remove patch
@@ -92,11 +92,11 @@  discard block
 block discarded – undo
92 92
     public function test_remember_saves_and_recover_values()
93 93
     {
94 94
         $this->cache->flushCache();
95
-        $value = $this->cache->remember('remember_test_key', 60, function () {
95
+        $value = $this->cache->remember('remember_test_key', 60, function() {
96 96
             return 'valor_teste';
97 97
         });
98 98
         $this->assertEquals('valor_teste', $value);
99
-        $cachedValue = $this->cache->remember('remember_test_key', 60, function(){
99
+        $cachedValue = $this->cache->remember('remember_test_key', 60, function() {
100 100
             return 'novo_valor';
101 101
         });
102 102
         $this->assertEquals('valor_teste', $cachedValue);
@@ -105,11 +105,11 @@  discard block
 block discarded – undo
105 105
     public function test_remember_forever_saves_value_indefinitely()
106 106
     {
107 107
         $this->cache->flushCache();
108
-        $value = $this->cache->rememberForever('remember_forever_key', function () {
108
+        $value = $this->cache->rememberForever('remember_forever_key', function() {
109 109
             return 'valor_eterno';
110 110
         });
111 111
         $this->assertEquals('valor_eterno', $value);
112
-        $cachedValue = $this->cache->rememberForever('remember_forever_key', function () {
112
+        $cachedValue = $this->cache->rememberForever('remember_forever_key', function() {
113 113
             return 'novo_valor';
114 114
         });
115 115
         $this->assertEquals('valor_eterno', $cachedValue);
Please login to merge, or discard this patch.
src/Cacheer.php 1 patch
Spacing   +6 added lines, -6 removed lines patch added patch discarded remove patch
@@ -86,7 +86,7 @@  discard block
 block discarded – undo
86 86
     * @param int|string $ttl
87 87
     * @return bool
88 88
     */
89
-    public function add(string $cacheKey, mixed $cacheData, string $namespace = '', int|string $ttl = 3600)
89
+    public function add(string $cacheKey, mixed $cacheData, string $namespace = '', int | string $ttl = 3600)
90 90
     {
91 91
         return $this->mutator->add($cacheKey, $cacheData, $namespace, $ttl);
92 92
     }
@@ -182,7 +182,7 @@  discard block
 block discarded – undo
182 182
     * @param string|int $ttl
183 183
     * @return CacheDataFormatter|mixed
184 184
     */
185
-    public function getCache(string $cacheKey, string $namespace = '', string|int $ttl = 3600)
185
+    public function getCache(string $cacheKey, string $namespace = '', string | int $ttl = 3600)
186 186
     {
187 187
         return $this->retriever->getCache($cacheKey, $namespace, $ttl);
188 188
     }
@@ -195,7 +195,7 @@  discard block
 block discarded – undo
195 195
     * @param string|int $ttl
196 196
     * @return CacheDataFormatter|mixed
197 197
     */
198
-    public function getMany(array $cacheKeys, string $namespace = '', string|int $ttl = 3600)
198
+    public function getMany(array $cacheKeys, string $namespace = '', string | int $ttl = 3600)
199 199
     {
200 200
         return $this->retriever->getMany($cacheKeys, $namespace, $ttl);
201 201
     }
@@ -244,7 +244,7 @@  discard block
 block discarded – undo
244 244
     * @param string|int $ttl
245 245
     * @return void
246 246
     */
247
-    public function putCache(string $cacheKey, mixed $cacheData, string $namespace = '', string|int $ttl = 3600): void
247
+    public function putCache(string $cacheKey, mixed $cacheData, string $namespace = '', string | int $ttl = 3600): void
248 248
     {
249 249
         $this->mutator->putCache($cacheKey, $cacheData, $namespace, $ttl);
250 250
     }
@@ -270,7 +270,7 @@  discard block
 block discarded – undo
270 270
     * @param string $namespace
271 271
     * @return void
272 272
     */
273
-    public function renewCache(string $cacheKey, string|int $ttl = 3600, string $namespace = ''): void
273
+    public function renewCache(string $cacheKey, string | int $ttl = 3600, string $namespace = ''): void
274 274
     {
275 275
         $this->mutator->renewCache($cacheKey, $ttl, $namespace);
276 276
     }
@@ -283,7 +283,7 @@  discard block
 block discarded – undo
283 283
     * @param Closure $callback
284 284
     * @return mixed
285 285
     */
286
-    public function remember(string $cacheKey, int|string $ttl, Closure $callback)
286
+    public function remember(string $cacheKey, int | string $ttl, Closure $callback)
287 287
     {
288 288
         return $this->retriever->remember($cacheKey, $ttl, $callback);
289 289
     }
Please login to merge, or discard this patch.