Passed
Push — main ( cf4bc2...db4fe2 )
by Sílvio
03:59 queued 01:05
created
src/Utils/CacheDriver.php 1 patch
Indentation   +10 added lines, -10 removed lines patch added patch discarded remove patch
@@ -65,8 +65,8 @@  discard block
 block discarded – undo
65 65
     }
66 66
 
67 67
     /**
68
-    * @return Cacheer
69
-    */
68
+     * @return Cacheer
69
+     */
70 70
     public function useArrayDriver()
71 71
     {
72 72
         $this->cacheer->cacheStore = new ArrayCacheStore($this->logPath);
@@ -75,7 +75,7 @@  discard block
 block discarded – undo
75 75
 
76 76
     /**
77 77
      * @return Cacheer
78
-    */
78
+     */
79 79
     public function useDefaultDriver()
80 80
     {
81 81
         if (!isset($this->cacheer->options['cacheDir'])) {
@@ -92,14 +92,14 @@  discard block
 block discarded – undo
92 92
     }
93 93
 
94 94
     /**
95
-    * @param mixed $dirName
96
-    * @return bool
97
-    */
95
+     * @param mixed $dirName
96
+     * @return bool
97
+     */
98 98
     private function isDir(mixed $dirName)
99 99
     {
100
-      if (is_dir($dirName)) {
101
-          return true;
102
-      }
103
-      return mkdir($dirName, 0755, true);
100
+        if (is_dir($dirName)) {
101
+            return true;
102
+        }
103
+        return mkdir($dirName, 0755, true);
104 104
     }
105 105
 }
Please login to merge, or discard this patch.
src/Helpers/CacheFileHelper.php 1 patch
Indentation   +15 added lines, -15 removed lines patch added patch discarded remove patch
@@ -14,9 +14,9 @@  discard block
 block discarded – undo
14 14
 {
15 15
 
16 16
     /**
17
-    * @param string $expiration
18
-    * @return int
19
-    */
17
+     * @param string $expiration
18
+     * @return int
19
+     */
20 20
     public static function convertExpirationToSeconds(string $expiration)
21 21
     {
22 22
         $units = [
@@ -58,10 +58,10 @@  discard block
 block discarded – undo
58 58
     }
59 59
 
60 60
     /**
61
-    * @param string|int $ttl
62
-    * @param int $defaultTTL
63
-    * @return mixed
64
-    */
61
+     * @param string|int $ttl
62
+     * @param int $defaultTTL
63
+     * @return mixed
64
+     */
65 65
     public static function ttl($ttl = null, ?int $defaultTTL = null) {
66 66
         if ($ttl) {
67 67
             $ttl = is_string($ttl) ? self::convertExpirationToSeconds($ttl) : $ttl;
@@ -71,13 +71,13 @@  discard block
 block discarded – undo
71 71
         return $ttl;
72 72
     }
73 73
 
74
-  /**
75
-  * @param mixed $currentCacheData
76
-  * @param mixed $cacheData
77
-  * @return array
78
-  */
79
-  public static function arrayIdentifier(mixed $currentCacheData, mixed $cacheData)
80
-  {
74
+    /**
75
+     * @param mixed $currentCacheData
76
+     * @param mixed $cacheData
77
+     * @return array
78
+     */
79
+    public static function arrayIdentifier(mixed $currentCacheData, mixed $cacheData)
80
+    {
81 81
     return CacheerHelper::arrayIdentifier($currentCacheData, $cacheData);
82
-  }
82
+    }
83 83
 }
Please login to merge, or discard this patch.
src/Exceptions/CacheRedisException.php 1 patch
Indentation   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -58,7 +58,7 @@
 block discarded – undo
58 58
      */
59 59
     public function toJson(int $options = 0)
60 60
     {
61
-      return parent::toJson($options);
61
+        return parent::toJson($options);
62 62
     }
63 63
 }
64 64
 
Please login to merge, or discard this patch.
src/Exceptions/CacheDatabaseException.php 2 patches
Indentation   +26 added lines, -26 removed lines patch added patch discarded remove patch
@@ -7,39 +7,39 @@  discard block
 block discarded – undo
7 7
 class CacheDatabaseException extends BaseException
8 8
 {
9 9
 
10
-  /** @param string $before */
11
-  private static string $before = "<Database Cache Store Exception>";
10
+    /** @param string $before */
11
+    private static string $before = "<Database Cache Store Exception>";
12 12
 
13
-  /**
14
-   * @param string $message
15
-   * @param int $code
16
-   * @param Exception|null $previous
17
-   * @param array $details
18
-   * @return self
19
-   */
20
-  public static function create(string $message = "", int $code = 0, ?Exception $previous = null, array $details = [])
21
-  {
13
+    /**
14
+     * @param string $message
15
+     * @param int $code
16
+     * @param Exception|null $previous
17
+     * @param array $details
18
+     * @return self
19
+     */
20
+    public static function create(string $message = "", int $code = 0, ?Exception $previous = null, array $details = [])
21
+    {
22 22
     return new self(self::getBefore() . ": " .$message, $code, $previous, $details);
23
-  }
23
+    }
24 24
 
25 25
 
26
-  /**
27
-  * @return string
28
-  */
29
-  public static function getBefore(): string
30
-  {
26
+    /**
27
+     * @return string
28
+     */
29
+    public static function getBefore(): string
30
+    {
31 31
     return self::$before;
32
-  }
32
+    }
33 33
 
34
-  /**
35
-  * @return void
36
-  */
37
-  public static function setBefore(string $text): void
38
-  {
34
+    /**
35
+     * @return void
36
+     */
37
+    public static function setBefore(string $text): void
38
+    {
39 39
     self::$before = $text;
40
-  }
40
+    }
41 41
 
42
-   /*
42
+    /*
43 43
     * @return array
44 44
     */
45 45
     public function toArray()
@@ -61,6 +61,6 @@  discard block
 block discarded – undo
61 61
      */
62 62
     public function toJson(int $options = 0)
63 63
     {
64
-      return parent::toJson($options);
64
+        return parent::toJson($options);
65 65
     }
66 66
 }
Please login to merge, or discard this 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/CacheStore/CacheManager/FileCacheManager.php 2 patches
Indentation   +22 added lines, -22 removed lines patch added patch discarded remove patch
@@ -15,9 +15,9 @@  discard block
 block discarded – undo
15 15
 {
16 16
 
17 17
     /**
18
-    * @param string $dir
19
-    * @return void
20
-    */
18
+     * @param string $dir
19
+     * @return void
20
+     */
21 21
     public function createDirectory(string $dir)
22 22
     {
23 23
         if ((!file_exists($dir) || !is_dir($dir)) && !mkdir($dir, 0755, true)) {
@@ -26,10 +26,10 @@  discard block
 block discarded – undo
26 26
     }
27 27
 
28 28
     /**
29
-    * @param string $filename
30
-    * @param string $data
31
-    * @return void
32
-    */
29
+     * @param string $filename
30
+     * @param string $data
31
+     * @return void
32
+     */
33 33
     public function writeFile(string $filename, string $data)
34 34
     {
35 35
         if (!@file_put_contents($filename, $data, LOCK_EX)) {
@@ -38,9 +38,9 @@  discard block
 block discarded – undo
38 38
     }
39 39
 
40 40
     /**
41
-    * @param string $filename
42
-    * @return string
43
-    */
41
+     * @param string $filename
42
+     * @return string
43
+     */
44 44
     public function readFile(string $filename)
45 45
     {
46 46
         if (!$this->fileExists($filename)) {
@@ -50,18 +50,18 @@  discard block
 block discarded – undo
50 50
     }
51 51
 
52 52
     /**
53
-    * @param string $filename
54
-    * @return bool
55
-    */
53
+     * @param string $filename
54
+     * @return bool
55
+     */
56 56
     public function fileExists(string $filename)
57 57
     {
58 58
         return file_exists($filename);
59 59
     }
60 60
 
61 61
     /**
62
-    * @param string $filename
63
-    * @return void
64
-    */
62
+     * @param string $filename
63
+     * @return void
64
+     */
65 65
     public function removeFile(string $filename)
66 66
     {
67 67
         if (file_exists($filename)) {
@@ -70,9 +70,9 @@  discard block
 block discarded – undo
70 70
     }
71 71
 
72 72
     /**
73
-    * @param string $dir
74
-    * @return void
75
-    */
73
+     * @param string $dir
74
+     * @return void
75
+     */
76 76
     public function clearDirectory(string $dir)
77 77
     {
78 78
         $iterator = new RecursiveIteratorIterator(
@@ -86,9 +86,9 @@  discard block
 block discarded – undo
86 86
     }
87 87
 
88 88
     /**
89
-    * @param mixed $data
90
-    * @param bool $serialize
91
-    */
89
+     * @param mixed $data
90
+     * @param bool $serialize
91
+     */
92 92
     public function serialize(mixed $data, bool $serialize = true)
93 93
     {
94 94
         if($serialize) {
Please login to merge, or discard this 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   +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 2 patches
Indentation   +196 added lines, -196 removed lines patch added patch discarded remove patch
@@ -13,124 +13,124 @@  discard block
 block discarded – undo
13 13
 class ArrayCacheStore implements CacheerInterface
14 14
 {
15 15
 
16
-  /**
17
-  * @param array $arrayStore
18
-  */
19
-  private array $arrayStore = [];
20
-
21
-  /**
22
-   * @param boolean
23
-   */
24
-  private bool $success = false;
25
-
26
-  /**
27
-   * @param string
28
-   */
29
-  private string $message = '';
30
-
31
-  /**
32
-   * @var CacheLogger
33
-   */
34
-  private $logger = null;
35
-
36
-  public function __construct(string $logPath)
37
-  {
16
+    /**
17
+     * @param array $arrayStore
18
+     */
19
+    private array $arrayStore = [];
20
+
21
+    /**
22
+     * @param boolean
23
+     */
24
+    private bool $success = false;
25
+
26
+    /**
27
+     * @param string
28
+     */
29
+    private string $message = '';
30
+
31
+    /**
32
+     * @var CacheLogger
33
+     */
34
+    private $logger = null;
35
+
36
+    public function __construct(string $logPath)
37
+    {
38 38
     $this->logger = new CacheLogger($logPath);
39
-  }
40
-
41
-  /**
42
-   * @param string $cacheKey
43
-   * @param mixed  $cacheData
44
-   * @param string $namespace
45
-   * @return bool
46
-   */
47
-  public function appendCache(string $cacheKey, mixed $cacheData, string $namespace = '')
48
-  {
49
-      $arrayStoreKey = $this->buildArrayKey($cacheKey, $namespace);
50
-
51
-      if (!$this->has($cacheKey, $namespace)) {
52
-          $this->setMessage("cacheData can't be appended, because doesn't exist or expired", false);
53
-          $this->logger->debug("{$this->getMessage()} from array driver.");
54
-          return false;
55
-      }
56
-
57
-      $this->arrayStore[$arrayStoreKey]['cacheData'] = serialize($cacheData);
58
-      $this->setMessage("Cache appended successfully", true);
59
-      return true;
60
-  }
61
-
62
-  /**
63
-   * @param string $cacheKey
64
-   * @param string $namespace
65
-   * @return string
66
-   */
67
-  private function buildArrayKey(string $cacheKey, string $namespace = '')
68
-  {
39
+    }
40
+
41
+    /**
42
+     * @param string $cacheKey
43
+     * @param mixed  $cacheData
44
+     * @param string $namespace
45
+     * @return bool
46
+     */
47
+    public function appendCache(string $cacheKey, mixed $cacheData, string $namespace = '')
48
+    {
49
+        $arrayStoreKey = $this->buildArrayKey($cacheKey, $namespace);
50
+
51
+        if (!$this->has($cacheKey, $namespace)) {
52
+            $this->setMessage("cacheData can't be appended, because doesn't exist or expired", false);
53
+            $this->logger->debug("{$this->getMessage()} from array driver.");
54
+            return false;
55
+        }
56
+
57
+        $this->arrayStore[$arrayStoreKey]['cacheData'] = serialize($cacheData);
58
+        $this->setMessage("Cache appended successfully", true);
59
+        return true;
60
+    }
61
+
62
+    /**
63
+     * @param string $cacheKey
64
+     * @param string $namespace
65
+     * @return string
66
+     */
67
+    private function buildArrayKey(string $cacheKey, string $namespace = '')
68
+    {
69 69
     return !empty($namespace) ? ($namespace . ':' . $cacheKey) : $cacheKey;
70
-  }
71
-
72
-  /**
73
-   * @param string $cacheKey
74
-   * @param string $namespace
75
-   * @return void
76
-   */
77
-  public function clearCache(string $cacheKey, string $namespace = '')
78
-  {
70
+    }
71
+
72
+    /**
73
+     * @param string $cacheKey
74
+     * @param string $namespace
75
+     * @return void
76
+     */
77
+    public function clearCache(string $cacheKey, string $namespace = '')
78
+    {
79 79
     $arrayStoreKey = $this->buildArrayKey($cacheKey, $namespace);
80 80
     unset($this->arrayStore[$arrayStoreKey]);
81 81
     $this->setMessage("Cache cleared successfully", true);
82 82
     $this->logger->debug("{$this->getMessage()} from array driver.");
83
-  }
84
-
85
-  /**
86
-   * @param string $cacheKey
87
-   * @param int $amount
88
-   * @param string $namespace
89
-   * @return bool
90
-   */
91
-  public function decrement(string $cacheKey, int $amount = 1, string $namespace = '')
92
-  {
83
+    }
84
+
85
+    /**
86
+     * @param string $cacheKey
87
+     * @param int $amount
88
+     * @param string $namespace
89
+     * @return bool
90
+     */
91
+    public function decrement(string $cacheKey, int $amount = 1, string $namespace = '')
92
+    {
93 93
     return $this->increment($cacheKey, ($amount * -1), $namespace);
94
-  }
94
+    }
95 95
 
96
-  /**
97
-   * @return void
98
-   */
99
-  public function flushCache()
100
-  {
96
+    /**
97
+     * @return void
98
+     */
99
+    public function flushCache()
100
+    {
101 101
     unset($this->arrayStore);
102 102
     $this->arrayStore = [];
103 103
     $this->setMessage("Cache flushed successfully", true);
104 104
     $this->logger->debug("{$this->getMessage()} from array driver.");
105
-  }
106
-
107
-  /**
108
-   * @param string $cacheKey
109
-   * @param mixed $cacheData
110
-   * @param string $namespace
111
-   * @param int|string $ttl
112
-   * @return void
113
-   */
114
-  public function forever(string $cacheKey, mixed $cacheData)
115
-  {
105
+    }
106
+
107
+    /**
108
+     * @param string $cacheKey
109
+     * @param mixed $cacheData
110
+     * @param string $namespace
111
+     * @param int|string $ttl
112
+     * @return void
113
+     */
114
+    public function forever(string $cacheKey, mixed $cacheData)
115
+    {
116 116
     $this->putCache($cacheKey, $cacheData, ttl: 31536000 * 1000);
117 117
     $this->setMessage($this->getMessage(), $this->isSuccess());
118
-  }
119
-
120
-  /**
121
-   * @param string $cacheKey
122
-   * @param string $namespace
123
-   * @param int|string $ttl
124
-   * @return mixed
125
-   */
126
-  public function getCache(string $cacheKey, string $namespace = '', string|int $ttl = 3600)
127
-  {
118
+    }
119
+
120
+    /**
121
+     * @param string $cacheKey
122
+     * @param string $namespace
123
+     * @param int|string $ttl
124
+     * @return mixed
125
+     */
126
+    public function getCache(string $cacheKey, string $namespace = '', string|int $ttl = 3600)
127
+    {
128 128
     $arrayStoreKey = $this->buildArrayKey($cacheKey, $namespace);
129 129
 
130 130
     if (!$this->has($cacheKey, $namespace)) {
131
-      $this->setMessage("cacheData not found, does not exists or expired", false);
132
-      $this->logger->debug("{$this->getMessage()} from array driver.");
133
-      return false;
131
+        $this->setMessage("cacheData not found, does not exists or expired", false);
132
+        $this->logger->debug("{$this->getMessage()} from array driver.");
133
+        return false;
134 134
     }
135 135
 
136 136
     $cacheData = $this->arrayStore[$arrayStoreKey];
@@ -138,112 +138,112 @@  discard block
 block discarded – undo
138 138
     $now = time();
139 139
 
140 140
     if($expirationTime !== 0 && $now >= $expirationTime) {
141
-      list($np, $key) = explode(':', $arrayStoreKey);
142
-      $this->clearCache($key, $np);
143
-      $this->setMessage("cacheKey: {$key} has expired.", false);
144
-      $this->logger->debug("{$this->getMessage()} from array driver.");
145
-      return false;
141
+        list($np, $key) = explode(':', $arrayStoreKey);
142
+        $this->clearCache($key, $np);
143
+        $this->setMessage("cacheKey: {$key} has expired.", false);
144
+        $this->logger->debug("{$this->getMessage()} from array driver.");
145
+        return false;
146 146
     }
147 147
 
148 148
     $this->setMessage("Cache retrieved successfully", true);
149 149
     $this->logger->debug("{$this->getMessage()} from array driver.");
150 150
     return $this->serialize($cacheData['cacheData'], false);
151
-  }
152
-
153
-  /**
154
-   * @param string $cacheKey
155
-   * @param string $namespace
156
-   * @return bool
157
-   */
158
-  public function has(string $cacheKey, string $namespace = '')
159
-  {
151
+    }
152
+
153
+    /**
154
+     * @param string $cacheKey
155
+     * @param string $namespace
156
+     * @return bool
157
+     */
158
+    public function has(string $cacheKey, string $namespace = '')
159
+    {
160 160
     $arrayStoreKey = $this->buildArrayKey($cacheKey, $namespace);
161 161
     return isset($this->arrayStore[$arrayStoreKey]) && time() < $this->arrayStore[$arrayStoreKey]['expirationTime'];
162
-  }
163
-
164
-  /**
165
-   * @param string $cacheKey
166
-   * @param int $amount
167
-   * @param string $namespace
168
-   * @return bool
169
-   */
170
-  public function increment(string $cacheKey, int $amount = 1, string $namespace = '')
171
-  {
162
+    }
163
+
164
+    /**
165
+     * @param string $cacheKey
166
+     * @param int $amount
167
+     * @param string $namespace
168
+     * @return bool
169
+     */
170
+    public function increment(string $cacheKey, int $amount = 1, string $namespace = '')
171
+    {
172 172
     $cacheData = $this->getCache($cacheKey, $namespace);
173 173
 
174 174
     if(!empty($cacheData) && is_numeric($cacheData)) {
175
-      $this->putCache($cacheKey, (int)($cacheData + $amount), $namespace);
176
-      $this->setMessage($this->getMessage(), $this->isSuccess());
177
-      return true;
175
+        $this->putCache($cacheKey, (int)($cacheData + $amount), $namespace);
176
+        $this->setMessage($this->getMessage(), $this->isSuccess());
177
+        return true;
178 178
     }
179 179
 
180 180
     return false;
181
-  }
181
+    }
182 182
 
183
-  /**
184
-   * @return boolean
185
-   */
186
-  public function isSuccess()
187
-  {
183
+    /**
184
+     * @return boolean
185
+     */
186
+    public function isSuccess()
187
+    {
188 188
     return $this->success;
189
-  }
189
+    }
190 190
 
191
-  /**
192
-   * @return string
193
-   */
194
-  public function getMessage()
195
-  {
191
+    /**
192
+     * @return string
193
+     */
194
+    public function getMessage()
195
+    {
196 196
     return $this->message;
197
-  }
198
-
199
-  /**
200
-   * @param string $cacheKey
201
-   * @param mixed $cacheData
202
-   * @param string $namespace
203
-   * @param int|string $ttl
204
-   * @return bool
205
-   */
206
-  public function putCache(string $cacheKey, mixed $cacheData, string $namespace = '', int|string $ttl = 3600)
207
-  {
197
+    }
198
+
199
+    /**
200
+     * @param string $cacheKey
201
+     * @param mixed $cacheData
202
+     * @param string $namespace
203
+     * @param int|string $ttl
204
+     * @return bool
205
+     */
206
+    public function putCache(string $cacheKey, mixed $cacheData, string $namespace = '', int|string $ttl = 3600)
207
+    {
208 208
     $arrayStoreKey = $this->buildArrayKey($cacheKey, $namespace);
209 209
 
210 210
     $this->arrayStore[$arrayStoreKey] = [
211
-      'cacheData' => serialize($cacheData),
212
-      'expirationTime' => time() + $ttl
211
+        'cacheData' => serialize($cacheData),
212
+        'expirationTime' => time() + $ttl
213 213
     ];
214 214
 
215 215
     $this->setMessage("Cache stored successfully", true);
216 216
     $this->logger->debug("{$this->getMessage()} from Array driver.");
217 217
     return true;
218
-  }
219
-
220
-  /**
221
-   * @param array $items
222
-   * @param string $namespace
223
-   * @param int $batchSize
224
-   * @return void
225
-   */
226
-  public function putMany(array $items, string $namespace = '', int $batchSize = 100)
227
-  {
218
+    }
219
+
220
+    /**
221
+     * @param array $items
222
+     * @param string $namespace
223
+     * @param int $batchSize
224
+     * @return void
225
+     */
226
+    public function putMany(array $items, string $namespace = '', int $batchSize = 100)
227
+    {
228 228
     $chunks = array_chunk($items, $batchSize, true);
229 229
 
230 230
     foreach ($chunks as $chunk) {
231
-      foreach ($chunk as $key => $data) {
232
-          $this->putCache($data['cacheKey'], $data['cacheData'], $namespace);
231
+        foreach ($chunk as $key => $data) {
232
+            $this->putCache($data['cacheKey'], $data['cacheData'], $namespace);
233
+        }
233 234
         }
234
-      }
235 235
     $this->setMessage("{$this->getMessage()}", $this->isSuccess());
236 236
     $this->logger->debug("{$this->getMessage()} from Array driver.");
237
-  }
238
-
239
-  /**
240
-   * @param string $cacheKey
241
-   * @param string|int $ttl
242
-   * @param string $namespace
243
-   * @return void
244
-   */
245
-  public function renewCache(string $cacheKey, int|string $ttl = 3600, string $namespace = '')
246
-  {
237
+    }
238
+
239
+    /**
240
+     * @param string $cacheKey
241
+     * @param string|int $ttl
242
+     * @param string $namespace
243
+     * @return void
244
+     */
245
+    public function renewCache(string $cacheKey, int|string $ttl = 3600, string $namespace = '')
246
+    {
247 247
     $arrayStoreKey = $this->buildArrayKey($cacheKey, $namespace);
248 248
 
249 249
     if (isset($this->arrayStore[$arrayStoreKey])) {
@@ -251,27 +251,27 @@  discard block
 block discarded – undo
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.");
254
-      }
255
-  }
256
-
257
-  /**
258
-   * @param string  $message
259
-   * @param boolean $success
260
-   * @return void
261
-   */
262
-  private function setMessage(string $message, bool $success)
263
-  {
254
+        }
255
+    }
256
+
257
+    /**
258
+     * @param string  $message
259
+     * @param boolean $success
260
+     * @return void
261
+     */
262
+    private function setMessage(string $message, bool $success)
263
+    {
264 264
     $this->message = $message;
265 265
     $this->success = $success;
266
-  }
267
-
268
-  /**
269
-   * @param mixed $data
270
-   * @param bool $serialize
271
-   * @return mixed
272
-   */
273
-  private function serialize(mixed $data, bool $serialize = true)
274
-  {
266
+    }
267
+
268
+    /**
269
+     * @param mixed $data
270
+     * @param bool $serialize
271
+     * @return mixed
272
+     */
273
+    private function serialize(mixed $data, bool $serialize = true)
274
+    {
275 275
     return $serialize ? serialize($data) : unserialize($data);
276
-  }
276
+    }
277 277
 }
Please login to merge, or discard this 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.
src/CacheStore/DatabaseCacheStore.php 1 patch
Spacing   +10 added lines, -10 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) {
@@ -165,9 +165,9 @@  discard block
 block discarded – undo
165 165
      * @param string|int $ttl
166 166
      * @return bool
167 167
      */
168
-    public function putCache(string $cacheKey, mixed $cacheData, string $namespace = '', string|int $ttl = 3600)
168
+    public function putCache(string $cacheKey, mixed $cacheData, string $namespace = '', string | int $ttl = 3600)
169 169
     {
170
-        if($this->storeCache($cacheKey, $cacheData, $namespace, $ttl)){
170
+        if ($this->storeCache($cacheKey, $cacheData, $namespace, $ttl)) {
171 171
             $this->logger->debug("{$this->getMessage()} from database driver.");
172 172
             return true;
173 173
         }
@@ -198,7 +198,7 @@  discard block
 block discarded – undo
198 198
      */
199 199
     private function processBatchItems(array $batchItems, string $namespace)
200 200
     {
201
-        foreach($batchItems as $item) {
201
+        foreach ($batchItems as $item) {
202 202
             CacheDatabaseHelper::validateCacheItem($item);
203 203
             $cacheKey = $item['cacheKey'];
204 204
             $cacheData = $item['cacheData'];
@@ -213,7 +213,7 @@  discard block
 block discarded – undo
213 213
      * @param string $namespace
214 214
      * @return bool
215 215
      */
216
-    private function renew(string $cacheKey, string|int $ttl = 3600, string $namespace = '')
216
+    private function renew(string $cacheKey, string | int $ttl = 3600, string $namespace = '')
217 217
     {
218 218
         $cacheData = $this->getCache($cacheKey, $namespace);
219 219
         if ($cacheData) {
@@ -256,10 +256,10 @@  discard block
 block discarded – undo
256 256
      * @param integer $ttl
257 257
      * @return bool
258 258
      */
259
-    private function storeCache(string $cacheKey, mixed $cacheData, string $namespace = '', string|int $ttl = 3600)
259
+    private function storeCache(string $cacheKey, mixed $cacheData, string $namespace = '', string | int $ttl = 3600)
260 260
     {
261 261
         $data = $this->cacheRepository->store($cacheKey, $cacheData, $namespace, $ttl);
262
-        if($data) {
262
+        if ($data) {
263 263
             $this->setMessage("Cache Stored Successfully", true);
264 264
             return true;
265 265
         }
@@ -276,7 +276,7 @@  discard block
 block discarded – undo
276 276
     private function updateCache(string $cacheKey, mixed $cacheData, string $namespace = '')
277 277
     {
278 278
         $data = $this->cacheRepository->update($cacheKey, $cacheData, $namespace);
279
-        if($data) {
279
+        if ($data) {
280 280
             $this->setMessage("Cache updated successfully.", true);
281 281
             return true;
282 282
         }
Please login to merge, or discard this patch.
src/Exceptions/ConnectionException.php 1 patch
Indentation   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -58,7 +58,7 @@
 block discarded – undo
58 58
      */
59 59
     public function toJson(int $options = 0)
60 60
     {
61
-      return parent::toJson($options);
61
+        return parent::toJson($options);
62 62
     }
63 63
 }
64 64
 
Please login to merge, or discard this patch.