Passed
Pull Request — main (#27)
by Sílvio
02:44
created
src/CacheStore/CacheManager/OptionBuilders/FileOptionBuilder.php 1 patch
Spacing   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -45,7 +45,7 @@  discard block
 block discarded – undo
45 45
       return $this;
46 46
     }
47 47
 
48
-    return new TimeBuilder(function ($formattedTime){
48
+    return new TimeBuilder(function($formattedTime) {
49 49
       $this->expirationTime = $formattedTime;
50 50
     }, $this);
51 51
   }
@@ -62,7 +62,7 @@  discard block
 block discarded – undo
62 62
       return $this;
63 63
     }
64 64
 
65
-    return new TimeBuilder(function ($formattedTime){
65
+    return new TimeBuilder(function($formattedTime) {
66 66
       $this->flushAfter = $formattedTime;
67 67
     }, $this);
68 68
   }
Please login to merge, or discard this patch.
src/CacheStore/FileCacheStore.php 1 patch
Spacing   +5 added lines, -5 removed lines patch added patch discarded remove patch
@@ -72,7 +72,7 @@  discard block
 block discarded – undo
72 72
      * @param string|int $ttl
73 73
      * @return string
74 74
      */
75
-    public function getCache(string $cacheKey, string $namespace = '', string|int $ttl = 3600)
75
+    public function getCache(string $cacheKey, string $namespace = '', string | int $ttl = 3600)
76 76
     {
77 77
        
78 78
         $ttl = CacheFileHelper::ttl($ttl, $this->defaultTTL);
@@ -96,7 +96,7 @@  discard block
 block discarded – undo
96 96
      * @param string|int $ttl
97 97
      * @return void
98 98
      */
99
-    public function putCache(string $cacheKey, mixed $cacheData, string $namespace = '', string|int $ttl = 3600)
99
+    public function putCache(string $cacheKey, mixed $cacheData, string $namespace = '', string | int $ttl = 3600)
100 100
     {
101 101
         $cacheFile = $this->buildCacheFilePath($cacheKey, $namespace);
102 102
         $data = $this->fileManager->serialize($cacheData);
@@ -171,7 +171,7 @@  discard block
 block discarded – undo
171 171
      * @param string $namespace
172 172
      * @return void
173 173
      */
174
-    public function renewCache(string $cacheKey, string|int $ttl, string $namespace = '')
174
+    public function renewCache(string $cacheKey, string | int $ttl, string $namespace = '')
175 175
     {
176 176
         $cacheData = $this->getCache($cacheKey, $namespace);
177 177
         if ($cacheData) {
@@ -278,12 +278,12 @@  discard block
 block discarded – undo
278 278
     {
279 279
         $flushAfterSeconds = CacheFileHelper::convertExpirationToSeconds($flushAfter);
280 280
 
281
-        if(!$this->fileManager->fileExists($this->lastFlushTimeFile)) {
281
+        if (!$this->fileManager->fileExists($this->lastFlushTimeFile)) {
282 282
             $this->fileManager->writeFile($this->lastFlushTimeFile, time());
283 283
             return;
284 284
         }
285 285
 
286
-        $lastFlushTime = (int) $this->fileManager->readFile($this->lastFlushTimeFile);
286
+        $lastFlushTime = (int)$this->fileManager->readFile($this->lastFlushTimeFile);
287 287
 
288 288
         if ((time() - $lastFlushTime) >= $flushAfterSeconds) {
289 289
             $this->flushCache();
Please login to merge, or discard this patch.
src/Repositories/CacheDatabaseRepository.php 1 patch
Spacing   +4 added lines, -4 removed lines patch added patch discarded remove patch
@@ -29,10 +29,10 @@  discard block
 block discarded – undo
29 29
      * @param string|int $ttl
30 30
      * @return bool
31 31
      */
32
-    public function store(string $cacheKey, mixed $cacheData, string $namespace, string|int $ttl = 3600)
32
+    public function store(string $cacheKey, mixed $cacheData, string $namespace, string | int $ttl = 3600)
33 33
     {
34 34
 
35
-        if(!empty($this->retrieve($cacheKey, $namespace))) {
35
+        if (!empty($this->retrieve($cacheKey, $namespace))) {
36 36
             $this->update($cacheKey, $cacheData, $namespace);
37 37
         }
38 38
 
@@ -115,7 +115,7 @@  discard block
 block discarded – undo
115 115
     * @param string $namespace
116 116
     * @return bool
117 117
     */
118
-    public function renew(string $cacheKey, string|int $ttl, string $namespace = '')
118
+    public function renew(string $cacheKey, string | int $ttl, string $namespace = '')
119 119
     {
120 120
         $currentTime = date('Y-m-d H:i:s');
121 121
 
@@ -135,7 +135,7 @@  discard block
 block discarded – undo
135 135
                 SET expirationTime = DATE_ADD(expirationTime, INTERVAL ? SECOND)
136 136
                 WHERE cacheKey = ? AND cacheNamespace = ? AND expirationTime > ?"
137 137
             );
138
-            $stmt->bindValue(1, (int) $ttl, PDO::PARAM_INT);
138
+            $stmt->bindValue(1, (int)$ttl, PDO::PARAM_INT);
139 139
             $stmt->bindValue(2, $cacheKey);
140 140
             $stmt->bindValue(3, $namespace);
141 141
             $stmt->bindValue(4, $currentTime);
Please login to merge, or discard this patch.
tests/Unit/FileCacheStoreTest.php 1 patch
Spacing   +4 added lines, -4 removed lines patch added patch discarded remove patch
@@ -258,13 +258,13 @@  discard block
 block discarded – undo
258 258
     {
259 259
         $this->cache->flushCache();
260 260
 
261
-        $value = $this->cache->remember('remember_test_key', 60, function () {
261
+        $value = $this->cache->remember('remember_test_key', 60, function() {
262 262
             return 'valor_teste';
263 263
         });
264 264
 
265 265
         $this->assertEquals('valor_teste', $value);
266 266
 
267
-        $cachedValue = $this->cache->remember('remember_test_key', 60, function (){
267
+        $cachedValue = $this->cache->remember('remember_test_key', 60, function() {
268 268
             return 'novo_valor';
269 269
         });
270 270
 
@@ -276,12 +276,12 @@  discard block
 block discarded – undo
276 276
     {
277 277
         $this->cache->flushCache();
278 278
 
279
-        $value = $this->cache->rememberForever('remember_forever_key', function () {
279
+        $value = $this->cache->rememberForever('remember_forever_key', function() {
280 280
             return 'valor_eterno';
281 281
         });
282 282
         $this->assertEquals('valor_eterno', $value);
283 283
 
284
-        $cachedValue = $this->cache->rememberForever('remember_forever_key', function () {
284
+        $cachedValue = $this->cache->rememberForever('remember_forever_key', function() {
285 285
             return 'novo_valor';
286 286
         });
287 287
 
Please login to merge, or discard this patch.
tests/Unit/DatabaseCacheStoreTest.php 1 patch
Spacing   +4 added lines, -4 removed lines patch added patch discarded remove patch
@@ -232,13 +232,13 @@  discard block
 block discarded – undo
232 232
 
233 233
     public function test_remember_saves_and_recover_values()
234 234
     {
235
-        $value = $this->cache->remember('remember_test_key', 60, function () {
235
+        $value = $this->cache->remember('remember_test_key', 60, function() {
236 236
             return 'valor_teste';
237 237
         });
238 238
 
239 239
         $this->assertEquals('valor_teste', $value);
240 240
 
241
-        $cachedValue = $this->cache->remember('remember_test_key', 60, function (){
241
+        $cachedValue = $this->cache->remember('remember_test_key', 60, function() {
242 242
             return 'novo_valor';
243 243
         });
244 244
 
@@ -249,12 +249,12 @@  discard block
 block discarded – undo
249 249
     public function test_remember_forever_saves_value_indefinitely()
250 250
     {
251 251
 
252
-        $value = $this->cache->rememberForever('remember_forever_key', function () {
252
+        $value = $this->cache->rememberForever('remember_forever_key', function() {
253 253
             return 'valor_eterno';
254 254
         });
255 255
         $this->assertEquals('valor_eterno', $value);
256 256
 
257
-        $cachedValue = $this->cache->rememberForever('remember_forever_key', function () {
257
+        $cachedValue = $this->cache->rememberForever('remember_forever_key', function() {
258 258
             return 'novo_valor';
259 259
         });
260 260
 
Please login to merge, or discard this patch.
tests/Unit/RedisCacheStoreTest.php 1 patch
Spacing   +4 added lines, -4 removed lines patch added patch discarded remove patch
@@ -258,13 +258,13 @@  discard block
 block discarded – undo
258 258
     {
259 259
         $this->cache->flushCache();
260 260
 
261
-        $value = $this->cache->remember('remember_test_key', 60, function () {
261
+        $value = $this->cache->remember('remember_test_key', 60, function() {
262 262
             return 'valor_teste';
263 263
         });
264 264
 
265 265
         $this->assertEquals('valor_teste', $value);
266 266
 
267
-        $cachedValue = $this->cache->remember('remember_test_key', 60, function (){
267
+        $cachedValue = $this->cache->remember('remember_test_key', 60, function() {
268 268
             return 'novo_valor';
269 269
         });
270 270
 
@@ -276,12 +276,12 @@  discard block
 block discarded – undo
276 276
     {
277 277
         $this->cache->flushCache();
278 278
 
279
-        $value = $this->cache->rememberForever('remember_forever_key', function () {
279
+        $value = $this->cache->rememberForever('remember_forever_key', function() {
280 280
             return 'valor_eterno';
281 281
         });
282 282
         $this->assertEquals('valor_eterno', $value);
283 283
 
284
-        $cachedValue = $this->cache->rememberForever('remember_forever_key', function () {
284
+        $cachedValue = $this->cache->rememberForever('remember_forever_key', function() {
285 285
             return 'novo_valor';
286 286
         });
287 287
 
Please login to merge, or discard this patch.
tests/Unit/ArrayCacheStoreTest.php 1 patch
Spacing   +4 added lines, -4 removed lines patch added patch discarded remove patch
@@ -258,13 +258,13 @@  discard block
 block discarded – undo
258 258
     {
259 259
         $this->cache->flushCache();
260 260
 
261
-        $value = $this->cache->remember('remember_test_key', 60, function () {
261
+        $value = $this->cache->remember('remember_test_key', 60, function() {
262 262
             return 'valor_teste';
263 263
         });
264 264
 
265 265
         $this->assertEquals('valor_teste', $value);
266 266
 
267
-        $cachedValue = $this->cache->remember('remember_test_key', 60, function (){
267
+        $cachedValue = $this->cache->remember('remember_test_key', 60, function() {
268 268
             return 'novo_valor';
269 269
         });
270 270
 
@@ -276,12 +276,12 @@  discard block
 block discarded – undo
276 276
     {
277 277
         $this->cache->flushCache();
278 278
 
279
-        $value = $this->cache->rememberForever('remember_forever_key', function () {
279
+        $value = $this->cache->rememberForever('remember_forever_key', function() {
280 280
             return 'valor_eterno';
281 281
         });
282 282
         $this->assertEquals('valor_eterno', $value);
283 283
 
284
-        $cachedValue = $this->cache->rememberForever('remember_forever_key', function () {
284
+        $cachedValue = $this->cache->rememberForever('remember_forever_key', function() {
285 285
             return 'novo_valor';
286 286
         });
287 287
 
Please login to merge, or discard this patch.
src/CacheStore/RedisCacheStore.php 1 patch
Spacing   +5 added lines, -5 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);
@@ -201,12 +201,12 @@  discard block
 block discarded – undo
201 201
      * @param string|int|null $ttl
202 202
      * @return mixed
203 203
      */
204
-    public function putCache(string $cacheKey, mixed $cacheData, string $namespace = '', string|int|null $ttl = null)
204
+    public function putCache(string $cacheKey, mixed $cacheData, string $namespace = '', string | int | null $ttl = null)
205 205
     {
206 206
         $cacheFullKey = $this->buildKey($cacheKey, $namespace);
207 207
         $serializedData = CacheRedisHelper::serialize($cacheData);
208 208
 
209
-        $result = $ttl ? $this->redis->setex($cacheFullKey, (int) $ttl, $serializedData)
209
+        $result = $ttl ? $this->redis->setex($cacheFullKey, (int)$ttl, $serializedData)
210 210
                        : $this->redis->set($cacheFullKey, $serializedData);
211 211
 
212 212
         if ($result) {
@@ -243,7 +243,7 @@  discard block
 block discarded – undo
243 243
      * @param string $namespace
244 244
      * @return void
245 245
      */
246
-    public function renewCache(string $cacheKey, string|int $ttl, string $namespace = '')
246
+    public function renewCache(string $cacheKey, string | int $ttl, string $namespace = '')
247 247
     {
248 248
         $cacheFullKey = $this->buildKey($cacheKey, $namespace);
249 249
         $dump = $this->getDump($cacheFullKey);
@@ -271,7 +271,7 @@  discard block
 block discarded – undo
271 271
      * @param mixed $dump
272 272
      * @return bool
273 273
      */
274
-    private function restoreKey(string $fullKey, string|int $ttl, mixed $dump)
274
+    private function restoreKey(string $fullKey, string | int $ttl, mixed $dump)
275 275
     {
276 276
         try {
277 277
             $this->redis->restore($fullKey, $ttl * 1000, $dump, 'REPLACE');
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
@@ -123,7 +123,7 @@  discard block
 block discarded – undo
123 123
    * @param int|string $ttl
124 124
    * @return mixed
125 125
    */
126
-  public function getCache(string $cacheKey, string $namespace = '', string|int $ttl = 3600)
126
+  public function getCache(string $cacheKey, string $namespace = '', string | int $ttl = 3600)
127 127
   {
128 128
     $arrayStoreKey = $this->buildArrayKey($cacheKey, $namespace);
129 129
 
@@ -137,7 +137,7 @@  discard block
 block discarded – undo
137 137
     $expirationTime = $cacheData['expirationTime'] ?? 0;
138 138
     $now = time();
139 139
 
140
-    if($expirationTime !== 0 && $now >= $expirationTime) {
140
+    if ($expirationTime !== 0 && $now >= $expirationTime) {
141 141
       list($np, $key) = explode(':', $arrayStoreKey);
142 142
       $this->clearCache($key, $np);
143 143
       $this->setMessage("cacheKey: {$key} has expired.", false);
@@ -171,7 +171,7 @@  discard block
 block discarded – undo
171 171
   {
172 172
     $cacheData = $this->getCache($cacheKey, $namespace);
173 173
 
174
-    if(!empty($cacheData) && is_numeric($cacheData)) {
174
+    if (!empty($cacheData) && is_numeric($cacheData)) {
175 175
       $this->putCache($cacheKey, (int)($cacheData + $amount), $namespace);
176 176
       $this->setMessage($this->getMessage(), $this->isSuccess());
177 177
       return true;
@@ -203,7 +203,7 @@  discard block
 block discarded – undo
203 203
    * @param int|string $ttl
204 204
    * @return bool
205 205
    */
206
-  public function putCache(string $cacheKey, mixed $cacheData, string $namespace = '', int|string $ttl = 3600)
206
+  public function putCache(string $cacheKey, mixed $cacheData, string $namespace = '', int | string $ttl = 3600)
207 207
   {
208 208
     $arrayStoreKey = $this->buildArrayKey($cacheKey, $namespace);
209 209
 
@@ -242,12 +242,12 @@  discard block
 block discarded – undo
242 242
    * @param string $namespace
243 243
    * @return void
244 244
    */
245
-  public function renewCache(string $cacheKey, int|string $ttl = 3600, string $namespace = '')
245
+  public function renewCache(string $cacheKey, int | string $ttl = 3600, string $namespace = '')
246 246
   {
247 247
     $arrayStoreKey = $this->buildArrayKey($cacheKey, $namespace);
248 248
 
249 249
     if (isset($this->arrayStore[$arrayStoreKey])) {
250
-        $ttlSeconds = is_numeric($ttl) ? (int) $ttl : strtotime($ttl) - time();
250
+        $ttlSeconds = is_numeric($ttl) ? (int)$ttl : strtotime($ttl) - time();
251 251
         $this->arrayStore[$arrayStoreKey]['expirationTime'] = time() + $ttlSeconds;
252 252
         $this->setMessage("cacheKey: {$cacheKey} renewed successfully", true);
253 253
         $this->logger->debug("{$this->getMessage()} from array driver.");
Please login to merge, or discard this patch.