Passed
Pull Request — main (#26)
by Sílvio
02:43
created
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.
src/CacheStore/ArrayCacheStore.php 1 patch
Spacing   +5 added lines, -5 removed lines patch added patch discarded remove patch
@@ -44,7 +44,7 @@  discard block
 block discarded – undo
44 44
   * @param int|string $ttl
45 45
   * @return mixed
46 46
   */
47
-  public function getCache(string $cacheKey, string $namespace = '', string|int $ttl = 3600)
47
+  public function getCache(string $cacheKey, string $namespace = '', string | int $ttl = 3600)
48 48
   {
49 49
 
50 50
     $arrayStoreKey = $this->buildArrayKey($cacheKey, $namespace);
@@ -59,7 +59,7 @@  discard block
 block discarded – undo
59 59
     $expirationTime = $cacheData['expirationTime'] ?? 0;
60 60
     $now = time();
61 61
 
62
-    if($expirationTime !== 0 && $now >= $expirationTime) {
62
+    if ($expirationTime !== 0 && $now >= $expirationTime) {
63 63
       list($np, $key) = explode(':', $arrayStoreKey);
64 64
       $this->clearCache($key, $np);
65 65
       $this->setMessage("cacheKey: {$key} has expired.", false);
@@ -79,7 +79,7 @@  discard block
 block discarded – undo
79 79
   * @param int|string $ttl
80 80
   * @return bool
81 81
   */
82
-  public function putCache(string $cacheKey, mixed $cacheData, string $namespace = '', int|string $ttl = 3600)
82
+  public function putCache(string $cacheKey, mixed $cacheData, string $namespace = '', int | string $ttl = 3600)
83 83
   {
84 84
 
85 85
     $arrayStoreKey = $this->buildArrayKey($cacheKey, $namespace);
@@ -159,12 +159,12 @@  discard block
 block discarded – undo
159 159
   * @param string $namespace
160 160
   * @return void
161 161
   */
162
-  public function renewCache(string $cacheKey, int|string $ttl = 3600, string $namespace = '')
162
+  public function renewCache(string $cacheKey, int | string $ttl = 3600, string $namespace = '')
163 163
   {
164 164
     $arrayStoreKey = $this->buildArrayKey($cacheKey, $namespace);
165 165
 
166 166
     if (isset($this->arrayStore[$arrayStoreKey])) {
167
-        $ttlSeconds = is_numeric($ttl) ? (int) $ttl : strtotime($ttl) - time();
167
+        $ttlSeconds = is_numeric($ttl) ? (int)$ttl : strtotime($ttl) - time();
168 168
         $this->arrayStore[$arrayStoreKey]['expirationTime'] = time() + $ttlSeconds;
169 169
         $this->setMessage("cacheKey: {$cacheKey} renewed successfully", true);
170 170
         $this->logger->debug("{$this->getMessage()} from array driver.");
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/Cacheer.php 1 patch
Spacing   +7 added lines, -7 removed lines patch added patch discarded remove patch
@@ -57,7 +57,7 @@  discard block
 block discarded – undo
57 57
      * @param string|int $ttl
58 58
      * @return CacheDataFormatter|mixed
59 59
      */
60
-    public function getCache(string $cacheKey, string $namespace = '', string|int $ttl = 3600)
60
+    public function getCache(string $cacheKey, string $namespace = '', string | int $ttl = 3600)
61 61
     {
62 62
         $cacheData = $this->cacheStore->getCache($cacheKey, $namespace, $ttl);
63 63
         $this->setMessage($this->cacheStore->getMessage(), $this->cacheStore->isSuccess());
@@ -71,7 +71,7 @@  discard block
 block discarded – undo
71 71
      * @param string|int $ttl
72 72
      * @return void
73 73
      */
74
-    public function putCache(string $cacheKey, mixed $cacheData, string $namespace = '', string|int $ttl = 3600)
74
+    public function putCache(string $cacheKey, mixed $cacheData, string $namespace = '', string | int $ttl = 3600)
75 75
     {
76 76
         $this->cacheStore->putCache($cacheKey, $cacheData, $namespace, $ttl);
77 77
         $this->setMessage($this->cacheStore->getMessage(), $this->cacheStore->isSuccess());
@@ -117,7 +117,7 @@  discard block
 block discarded – undo
117 117
      * @param string $namespace
118 118
      * @return mixed
119 119
      */
120
-    public function renewCache(string $cacheKey, string|int $ttl = 3600, string $namespace = '')
120
+    public function renewCache(string $cacheKey, string | int $ttl = 3600, string $namespace = '')
121 121
     {
122 122
         $renewedCache = $this->cacheStore->renewCache($cacheKey, $ttl, $namespace);
123 123
 
@@ -140,7 +140,7 @@  discard block
 block discarded – undo
140 140
     {
141 141
         $cacheData = $this->getCache($cacheKey, $namespace);
142 142
 
143
-        if(!empty($cacheData) && is_numeric($cacheData)) {
143
+        if (!empty($cacheData) && is_numeric($cacheData)) {
144 144
             $this->putCache($cacheKey, (int)($cacheData + $amount), $namespace);
145 145
             $this->setMessage($this->getMessage(), $this->isSuccess());
146 146
             return true;
@@ -176,11 +176,11 @@  discard block
 block discarded – undo
176 176
     * @param Closure $callback
177 177
     * @return mixed
178 178
     */
179
-    public function remember(string $cacheKey, int|string $ttl, Closure $callback)
179
+    public function remember(string $cacheKey, int | string $ttl, Closure $callback)
180 180
     {
181 181
         $cachedData = $this->getCache($cacheKey, ttl: $ttl);
182 182
 
183
-        if(!empty($cachedData)) {
183
+        if (!empty($cachedData)) {
184 184
             return $cachedData;
185 185
         }
186 186
 
@@ -225,7 +225,7 @@  discard block
 block discarded – undo
225 225
     * @param int|string $ttl
226 226
     * @return bool
227 227
     */
228
-    public function add(string $cacheKey, mixed $cacheData, string $namespace = '', int|string $ttl = 3600)
228
+    public function add(string $cacheKey, mixed $cacheData, string $namespace = '', int | string $ttl = 3600)
229 229
     {
230 230
         if (!empty($this->getCache($cacheKey, $namespace))) {
231 231
             return true;
Please login to merge, or discard this patch.
src/Exceptions/CacheDatabaseException.php 1 patch
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -19,7 +19,7 @@
 block discarded – undo
19 19
    */
20 20
   public static function create(string $message = "", int $code = 0, ?Exception $previous = null, array $details = [])
21 21
   {
22
-    return new self(self::getBefore() . ": " .$message, $code, $previous, $details);
22
+    return new self(self::getBefore() . ": " . $message, $code, $previous, $details);
23 23
   }
24 24
 
25 25
 
Please login to merge, or discard this patch.