Passed
Pull Request — main (#60)
by Sílvio
03:30
created
src/Helpers/CacheRedisHelper.php 2 patches
Indentation   +27 added lines, -27 removed lines patch added patch discarded remove patch
@@ -13,29 +13,29 @@  discard block
 block discarded – undo
13 13
 class CacheRedisHelper
14 14
 {
15 15
 
16
-  /**
17
-  * serializes or unserializes data based on the $serialize flag.
18
-  * 
19
-  * @param mixed $data
20
-  * @param bool  $serialize
21
-  * @return mixed
22
-  */
23
-  public static function serialize(mixed $data, bool $serialize = true): mixed
24
-  {
16
+    /**
17
+     * serializes or unserializes data based on the $serialize flag.
18
+     * 
19
+     * @param mixed $data
20
+     * @param bool  $serialize
21
+     * @return mixed
22
+     */
23
+    public static function serialize(mixed $data, bool $serialize = true): mixed
24
+    {
25 25
     if($serialize) {
26
-      return serialize($data);
26
+        return serialize($data);
27 27
     }
28 28
 
29 29
     return unserialize($data);
30 30
 
31
-  }
31
+    }
32 32
 
33 33
     /**
34
-    * Validates a cache item.
35
-    *  
36
-    * @param array $item
37
-    * @return void
38
-    */
34
+     * Validates a cache item.
35
+     *  
36
+     * @param array $item
37
+     * @return void
38
+     */
39 39
     public static function validateCacheItem(array $item): void
40 40
     {
41 41
         CacheerHelper::validateCacheItem(
@@ -55,17 +55,17 @@  discard block
 block discarded – undo
55 55
         return CacheerHelper::mergeCacheData($cacheData);
56 56
     }
57 57
 
58
-  /**
59
-  * Generates an array identifier for cache data.
60
-  * 
61
-  * @param mixed $currentCacheData
62
-  * @param mixed $cacheData
63
-  * @return array
64
-  */
65
-  public static function arrayIdentifier(mixed $currentCacheData, mixed $cacheData): array
66
-  {
67
-      return CacheerHelper::arrayIdentifier($currentCacheData, $cacheData);
68
-  }
58
+    /**
59
+     * Generates an array identifier for cache data.
60
+     * 
61
+     * @param mixed $currentCacheData
62
+     * @param mixed $cacheData
63
+     * @return array
64
+     */
65
+    public static function arrayIdentifier(mixed $currentCacheData, mixed $cacheData): array
66
+    {
67
+        return CacheerHelper::arrayIdentifier($currentCacheData, $cacheData);
68
+    }
69 69
 
70 70
 }
71 71
 
Please login to merge, or discard this patch.
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -22,7 +22,7 @@
 block discarded – undo
22 22
   */
23 23
   public static function serialize(mixed $data, bool $serialize = true): mixed
24 24
   {
25
-    if($serialize) {
25
+    if ($serialize) {
26 26
       return serialize($data);
27 27
     }
28 28
 
Please login to merge, or discard this patch.
src/Service/CacheMutator.php 2 patches
Indentation   +52 added lines, -52 removed lines patch added patch discarded remove patch
@@ -13,29 +13,29 @@  discard block
 block discarded – undo
13 13
 class CacheMutator
14 14
 {
15 15
     /**
16
-    * @var Cacheer
17
-    */
16
+     * @var Cacheer
17
+     */
18 18
     private Cacheer $cacheer;
19 19
 
20 20
     /**
21
-    * CacheMutator constructor.
22
-    *
23
-    * @param Cacheer $cacheer
24
-    */
21
+     * CacheMutator constructor.
22
+     *
23
+     * @param Cacheer $cacheer
24
+     */
25 25
     public function __construct(Cacheer $cacheer)
26 26
     {
27 27
         $this->cacheer = $cacheer;
28 28
     }
29 29
 
30 30
     /**
31
-    * Adds a cache item if it does not already exist.
32
-    *
33
-    * @param string $cacheKey
34
-    * @param mixed $cacheData
35
-    * @param string $namespace
36
-    * @param int|string $ttl
37
-    * @return bool
38
-    */
31
+     * Adds a cache item if it does not already exist.
32
+     *
33
+     * @param string $cacheKey
34
+     * @param mixed $cacheData
35
+     * @param string $namespace
36
+     * @param int|string $ttl
37
+     * @return bool
38
+     */
39 39
     public function add(string $cacheKey, mixed $cacheData, string $namespace = '', int|string $ttl = 3600): bool
40 40
     {
41 41
         if (!empty($this->cacheer->getCache($cacheKey, $namespace))) {
@@ -49,13 +49,13 @@  discard block
 block discarded – undo
49 49
     }
50 50
 
51 51
     /**
52
-    * Appends data to an existing cache item.
53
-    *
54
-    * @param string $cacheKey
55
-    * @param mixed $cacheData
56
-    * @param string $namespace
57
-    * @return bool
58
-    */
52
+     * Appends data to an existing cache item.
53
+     *
54
+     * @param string $cacheKey
55
+     * @param mixed $cacheData
56
+     * @param string $namespace
57
+     * @return bool
58
+     */
59 59
     public function appendCache(string $cacheKey, mixed $cacheData, string $namespace = ''): bool
60 60
     {
61 61
         $this->cacheer->cacheStore->appendCache($cacheKey, $cacheData, $namespace);
@@ -65,12 +65,12 @@  discard block
 block discarded – undo
65 65
     }
66 66
 
67 67
     /**
68
-    * Clears a specific cache item.
69
-    *
70
-    * @param string $cacheKey
71
-    * @param string $namespace
72
-    * @return bool
73
-    */
68
+     * Clears a specific cache item.
69
+     *
70
+     * @param string $cacheKey
71
+     * @param string $namespace
72
+     * @return bool
73
+     */
74 74
     public function clearCache(string $cacheKey, string $namespace = ''): bool
75 75
     {
76 76
         $this->cacheer->cacheStore->clearCache($cacheKey, $namespace);
@@ -80,13 +80,13 @@  discard block
 block discarded – undo
80 80
     }
81 81
 
82 82
     /**
83
-    * Decrements a numeric cache item by a specified amount.
84
-    *
85
-    * @param string $cacheKey
86
-    * @param int $amount
87
-    * @param string $namespace
88
-    * @return bool
89
-    */
83
+     * Decrements a numeric cache item by a specified amount.
84
+     *
85
+     * @param string $cacheKey
86
+     * @param int $amount
87
+     * @param string $namespace
88
+     * @return bool
89
+     */
90 90
     public function decrement(string $cacheKey, int $amount = 1, string $namespace = ''): bool
91 91
     {
92 92
         return $this->increment($cacheKey, ($amount * -1), $namespace);
@@ -108,10 +108,10 @@  discard block
 block discarded – undo
108 108
     }
109 109
 
110 110
     /**
111
-    * Flushes the entire cache.
112
-    *
113
-    * @return bool
114
-    */
111
+     * Flushes the entire cache.
112
+     *
113
+     * @return bool
114
+     */
115 115
     public function flushCache(): bool
116 116
     {
117 117
         $this->cacheer->cacheStore->flushCache();
@@ -160,13 +160,13 @@  discard block
 block discarded – undo
160 160
     }
161 161
 
162 162
     /**
163
-    * Puts multiple cache items in a batch.
164
-    *
165
-    * @param array $items
166
-    * @param string $namespace
167
-    * @param int $batchSize
168
-    * @return bool
169
-    */
163
+     * Puts multiple cache items in a batch.
164
+     *
165
+     * @param array $items
166
+     * @param string $namespace
167
+     * @param int $batchSize
168
+     * @return bool
169
+     */
170 170
     public function putMany(array $items, string $namespace = '', int $batchSize = 100): bool
171 171
     {
172 172
         $this->cacheer->cacheStore->putMany($items, $namespace, $batchSize);
@@ -176,13 +176,13 @@  discard block
 block discarded – undo
176 176
     }
177 177
 
178 178
     /**
179
-    * Renews the cache item with a new TTL.
180
-    *
181
-    * @param string $cacheKey
182
-    * @param int|string $ttl
183
-    * @param string $namespace
184
-    * @return bool
185
-    */
179
+     * Renews the cache item with a new TTL.
180
+     *
181
+     * @param string $cacheKey
182
+     * @param int|string $ttl
183
+     * @param string $namespace
184
+     * @return bool
185
+     */
186 186
     public function renewCache(string $cacheKey, int|string $ttl = 3600, string $namespace = ''): bool
187 187
     {
188 188
         $this->cacheer->cacheStore->renewCache($cacheKey, $ttl, $namespace);
Please login to merge, or discard this patch.
Spacing   +3 added lines, -3 removed lines patch added patch discarded remove patch
@@ -36,7 +36,7 @@  discard block
 block discarded – undo
36 36
     * @param int|string $ttl
37 37
     * @return bool
38 38
     */
39
-    public function add(string $cacheKey, mixed $cacheData, string $namespace = '', int|string $ttl = 3600): bool
39
+    public function add(string $cacheKey, mixed $cacheData, string $namespace = '', int | string $ttl = 3600): bool
40 40
     {
41 41
         if (!empty($this->cacheer->getCache($cacheKey, $namespace))) {
42 42
             return true;
@@ -150,7 +150,7 @@  discard block
 block discarded – undo
150 150
      * @param int|string $ttl
151 151
      * @return bool
152 152
      */
153
-    public function putCache(string $cacheKey, mixed $cacheData, string $namespace = '', int|string $ttl = 3600): bool
153
+    public function putCache(string $cacheKey, mixed $cacheData, string $namespace = '', int | string $ttl = 3600): bool
154 154
     {
155 155
         $data = CacheerHelper::prepareForStorage($cacheData, $this->cacheer->isCompressionEnabled(), $this->cacheer->getEncryptionKey());
156 156
         $this->cacheer->cacheStore->putCache($cacheKey, $data, $namespace, $ttl);
@@ -183,7 +183,7 @@  discard block
 block discarded – undo
183 183
     * @param string $namespace
184 184
     * @return bool
185 185
     */
186
-    public function renewCache(string $cacheKey, int|string $ttl = 3600, string $namespace = ''): bool
186
+    public function renewCache(string $cacheKey, int | string $ttl = 3600, string $namespace = ''): bool
187 187
     {
188 188
         $this->cacheer->cacheStore->renewCache($cacheKey, $ttl, $namespace);
189 189
         $this->cacheer->syncState();
Please login to merge, or discard this patch.
tests/Unit/StaticAccessTest.php 1 patch
Indentation   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -35,8 +35,8 @@
 block discarded – undo
35 35
             'driver' => 'file',
36 36
             'path' => '/tmp/cache',
37 37
         ];
38
-       Cacheer::setUp($options);
39
-       self::assertSame($options, Cacheer::getOptions());
38
+        Cacheer::setUp($options);
39
+        self::assertSame($options, Cacheer::getOptions());
40 40
     }
41 41
 
42 42
     public function testSetUpStaticWithOptionBuilder(): void
Please login to merge, or discard this patch.
src/Cacheer.php 2 patches
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -90,7 +90,7 @@
 block discarded – undo
90 90
     /**
91 91
     * @var FileCacheStore|DatabaseCacheStore|RedisCacheStore|ArrayCacheStore
92 92
     */
93
-    public RedisCacheStore|DatabaseCacheStore|ArrayCacheStore|FileCacheStore $cacheStore;
93
+    public RedisCacheStore | DatabaseCacheStore | ArrayCacheStore | FileCacheStore $cacheStore;
94 94
 
95 95
     /**
96 96
     * @var array
Please login to merge, or discard this patch.
Indentation   +60 added lines, -60 removed lines patch added patch discarded remove patch
@@ -67,66 +67,66 @@  discard block
 block discarded – undo
67 67
 final class Cacheer
68 68
 {
69 69
     /**
70
-    * @var string
71
-    */
70
+     * @var string
71
+     */
72 72
     private string $message;
73 73
 
74 74
     /**
75
-    * @var boolean
76
-    */
75
+     * @var boolean
76
+     */
77 77
     private bool $success;
78 78
 
79 79
     /**
80
-    * @var boolean
81
-    */
80
+     * @var boolean
81
+     */
82 82
     private bool $formatted = false;
83 83
 
84 84
     /**
85
-    * @var bool
86
-    */
85
+     * @var bool
86
+     */
87 87
     private bool $compression = false;
88 88
 
89 89
     /**
90
-    * @var string|null
91
-    */
90
+     * @var string|null
91
+     */
92 92
     private ?string $encryptionKey = null;
93 93
 
94 94
     /**
95
-    * @var FileCacheStore|DatabaseCacheStore|RedisCacheStore|ArrayCacheStore
96
-    */
95
+     * @var FileCacheStore|DatabaseCacheStore|RedisCacheStore|ArrayCacheStore
96
+     */
97 97
     public RedisCacheStore|DatabaseCacheStore|ArrayCacheStore|FileCacheStore $cacheStore;
98 98
 
99 99
     /**
100
-    * @var array
101
-    */
100
+     * @var array
101
+     */
102 102
     public array $options = [];
103 103
 
104 104
     /**
105
-    * @var CacheRetriever
106
-    */
105
+     * @var CacheRetriever
106
+     */
107 107
     private CacheRetriever $retriever;
108 108
 
109 109
     /**
110
-    * @var CacheMutator
111
-    */
110
+     * @var CacheMutator
111
+     */
112 112
     private CacheMutator $mutator;
113 113
 
114 114
     /**
115
-    * @var CacheConfig
116
-    */
115
+     * @var CacheConfig
116
+     */
117 117
     private CacheConfig $config;
118 118
 
119 119
     /**
120
-    * @var Cacheer|null
121
-    */
120
+     * @var Cacheer|null
121
+     */
122 122
     private static ?Cacheer $staticInstance = null;
123 123
 
124 124
 /**
125
-    * Cacheer constructor.
126
-    *
127
-    * @param array $options
128
-    * @param bool  $formatted
129
-    * @throws RuntimeException|Exceptions\CacheFileException
125
+ * Cacheer constructor.
126
+ *
127
+ * @param array $options
128
+ * @param bool  $formatted
129
+ * @throws RuntimeException|Exceptions\CacheFileException
130 130
  */
131 131
     public function __construct(array $options = [], bool $formatted = false)
132 132
     {
@@ -186,11 +186,11 @@  discard block
 block discarded – undo
186 186
     }
187 187
 
188 188
     /**
189
-    * Enable encryption for cached data
190
-    *
191
-    * @param string $key
192
-    * @return Cacheer
193
-    */
189
+     * Enable encryption for cached data
190
+     *
191
+     * @param string $key
192
+     * @return Cacheer
193
+     */
194 194
     public function useEncryption(string $key): Cacheer
195 195
     {
196 196
         $this->encryptionKey = $key;
@@ -198,11 +198,11 @@  discard block
 block discarded – undo
198 198
     }
199 199
 
200 200
     /**
201
-    * Enable or disable data compression
202
-    *
203
-    * @param bool $status
204
-    * @return Cacheer
205
-    */
201
+     * Enable or disable data compression
202
+     *
203
+     * @param bool $status
204
+     * @return Cacheer
205
+     */
206 206
     public function useCompression(bool $status = true): Cacheer
207 207
     {
208 208
         $this->compression = $status;
@@ -210,43 +210,43 @@  discard block
 block discarded – undo
210 210
     }
211 211
 
212 212
     /**
213
-    * Enables or disables the formatter for cache data.
214
-    * 
215
-    * @return void
216
-    */
213
+     * Enables or disables the formatter for cache data.
214
+     * 
215
+     * @return void
216
+     */
217 217
     public function useFormatter(): void
218 218
     {
219 219
         $this->formatted = !$this->formatted;
220 220
     }
221 221
 
222 222
     /**
223
-    * Validates the options provided for the Cacheer instance.
224
-    * 
225
-    * @param array $options
226
-    * @return void
227
-    */
223
+     * Validates the options provided for the Cacheer instance.
224
+     * 
225
+     * @param array $options
226
+     * @return void
227
+     */
228 228
     private function validateOptions(array $options): void
229 229
     {
230 230
         $this->options = $options;
231 231
     }
232 232
 
233 233
     /**
234
-    * Checks if the last operation was successful.
235
-    * 
236
-    * @return bool
237
-    */
234
+     * Checks if the last operation was successful.
235
+     * 
236
+     * @return bool
237
+     */
238 238
     public function isSuccess(): bool
239 239
     {
240 240
         return $this->success;
241 241
     }
242 242
 
243 243
     /**
244
-    * Sets a message for the cache operation.
245
-    *
246
-    * @param string  $message
247
-    * @param boolean $success
248
-    * @return void
249
-    */
244
+     * Sets a message for the cache operation.
245
+     *
246
+     * @param string  $message
247
+     * @param boolean $success
248
+     * @return void
249
+     */
250 250
     private function setMessage(string $message, bool $success): void
251 251
     {
252 252
         $this->message = $message;
@@ -254,10 +254,10 @@  discard block
 block discarded – undo
254 254
     }
255 255
 
256 256
     /**
257
-    * Retrieves the message from the last operation.
258
-    * 
259
-    * @return string
260
-    */
257
+     * Retrieves the message from the last operation.
258
+     * 
259
+     * @return string
260
+     */
261 261
     public function getMessage(): string
262 262
     {
263 263
         return $this->message;
Please login to merge, or discard this patch.