Passed
Push — main ( cd5745...cfa081 )
by Sílvio
10:20 queued 07:29
created
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.
src/Repositories/CacheDatabaseRepository.php 1 patch
Spacing   +3 added lines, -3 removed lines patch added patch discarded remove patch
@@ -29,7 +29,7 @@  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
         if (!empty($this->retrieve($cacheKey, $namespace))) {
35 35
             return $this->update($cacheKey, $cacheData, $namespace);
@@ -174,7 +174,7 @@  discard block
 block discarded – undo
174 174
     * @param string $namespace
175 175
     * @return bool
176 176
     */
177
-    public function renew(string $cacheKey, string|int $ttl, string $namespace = '')
177
+    public function renew(string $cacheKey, string | int $ttl, string $namespace = '')
178 178
     {
179 179
         $currentTime = date('Y-m-d H:i:s');
180 180
         if (!$this->hasValidCache($cacheKey, $namespace, $currentTime)) {
@@ -183,7 +183,7 @@  discard block
 block discarded – undo
183 183
 
184 184
         $query = $this->getRenewExpirationQueryWithDriver();
185 185
         $stmt = $this->connection->prepare($query);
186
-        $stmt->bindValue(':ttl', (int) $ttl, PDO::PARAM_INT);
186
+        $stmt->bindValue(':ttl', (int)$ttl, PDO::PARAM_INT);
187 187
         $stmt->bindValue(':cacheKey', $cacheKey);
188 188
         $stmt->bindValue(':namespace', $namespace);
189 189
         $stmt->bindValue(':currentTime', $currentTime);
Please login to merge, or discard this patch.
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.