Passed
Pull Request — main (#39)
by Sílvio
13:07
created
src/Exceptions/CacheDatabaseException.php 1 patch
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.
src/CacheStore/CacheManager/FileCacheManager.php 1 patch
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.
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.
src/Exceptions/CacheFileException.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.
tests/Feature/OptionBuildTest.php 1 patch
Indentation   +38 added lines, -38 removed lines patch added patch discarded remove patch
@@ -7,26 +7,26 @@  discard block
 block discarded – undo
7 7
 class OptionBuildTest extends TestCase
8 8
 {
9 9
 
10
-  private $cache;
11
-  private $cacheDir;
10
+    private $cache;
11
+    private $cacheDir;
12 12
 
13
-  protected function setUp(): void
14
-  {
13
+    protected function setUp(): void
14
+    {
15 15
     $this->cacheDir = __DIR__ . '/cache';
16 16
     if (!file_exists($this->cacheDir) || !is_dir($this->cacheDir)) {
17
-      mkdir($this->cacheDir, 0755, true);
17
+        mkdir($this->cacheDir, 0755, true);
18 18
     }
19 19
 
20 20
     $this->cache = new Cacheer();
21
-  }
21
+    }
22 22
 
23
-  protected function tearDown(): void
24
-  {
23
+    protected function tearDown(): void
24
+    {
25 25
     $this->cache->flushCache();
26
-  }
26
+    }
27 27
 
28
-  public function test_it_can_set_cache_directory()
29
-  {
28
+    public function test_it_can_set_cache_directory()
29
+    {
30 30
     $cacheDir = __DIR__ . "/cache";
31 31
 
32 32
     $options = OptionBuilder::forFile()
@@ -35,23 +35,23 @@  discard block
 block discarded – undo
35 35
 
36 36
     $this->assertArrayHasKey('cacheDir', $options);
37 37
     $this->assertEquals($cacheDir, $options['cacheDir']);
38
-  }
38
+    }
39 39
 
40 40
 
41
-  public function test_it_can_set_expiration_time()
41
+    public function test_it_can_set_expiration_time()
42 42
     {
43 43
 
44
-      $options = OptionBuilder::forFile()
45
-      ->expirationTime('2 hours')
46
-      ->build();
44
+        $options = OptionBuilder::forFile()
45
+        ->expirationTime('2 hours')
46
+        ->build();
47 47
       
48
-      $this->assertArrayHasKey('expirationTime', $options);
49
-      $this->assertEquals('2 hours', $options['expirationTime']);
48
+        $this->assertArrayHasKey('expirationTime', $options);
49
+        $this->assertEquals('2 hours', $options['expirationTime']);
50 50
     }
51 51
 
52 52
     public function test_it_can_set_flush_after()
53 53
     {
54
-      $options = OptionBuilder::forFile()
54
+        $options = OptionBuilder::forFile()
55 55
         ->flushAfter('11 seconds')
56 56
         ->build();
57 57
 
@@ -61,9 +61,9 @@  discard block
 block discarded – undo
61 61
 
62 62
     public function test_it_can_set_multiple_options_together()
63 63
     {
64
-      $cacheDir = __DIR__ . "/cache";
64
+        $cacheDir = __DIR__ . "/cache";
65 65
 
66
-      $options = OptionBuilder::forFile()
66
+        $options = OptionBuilder::forFile()
67 67
             ->dir($cacheDir)
68 68
             ->expirationTime('1 day')
69 69
             ->flushAfter('30 minutes')
@@ -76,41 +76,41 @@  discard block
 block discarded – undo
76 76
         ], $options);
77 77
     }
78 78
 
79
-  public function test_it_allows_setting_expiration_time_with_timebuilder()
79
+    public function test_it_allows_setting_expiration_time_with_timebuilder()
80 80
     {
81
-      $options = OptionBuilder::forFile()->expirationTime()->week(1)->build();
82
-      $this->assertArrayHasKey('expirationTime', $options);
83
-      $this->assertEquals('1 weeks', $options['expirationTime']);
81
+        $options = OptionBuilder::forFile()->expirationTime()->week(1)->build();
82
+        $this->assertArrayHasKey('expirationTime', $options);
83
+        $this->assertEquals('1 weeks', $options['expirationTime']);
84 84
     }
85 85
 
86
-  public function test_it_allows_setting_flush_after_with_timebuilder()
87
-  {
86
+    public function test_it_allows_setting_flush_after_with_timebuilder()
87
+    {
88 88
     $options = OptionBuilder::forFile()->flushAfter()->second(10)->build();
89 89
     $this->assertArrayHasKey('flushAfter', $options);
90 90
     $this->assertEquals('10 seconds', $options['flushAfter']);
91
-  }
91
+    }
92 92
 
93
-  public function test_it_can_set_multiple_options_together_with_timebuilder()
94
-  {
93
+    public function test_it_can_set_multiple_options_together_with_timebuilder()
94
+    {
95 95
     $cacheDir = __DIR__ . "/cache";
96 96
     $options = OptionBuilder::forFile()
97
-          ->dir($cacheDir)
98
-          ->expirationTime()->week(1)
99
-          ->flushAfter()->minute(10)
100
-          ->build();
97
+            ->dir($cacheDir)
98
+            ->expirationTime()->week(1)
99
+            ->flushAfter()->minute(10)
100
+            ->build();
101 101
 
102 102
     $this->assertEquals([
103 103
             'cacheDir' => $cacheDir,
104 104
             'expirationTime' => '1 weeks',
105 105
             'flushAfter' => '10 minutes',
106 106
         ], $options);
107
-  }
107
+    }
108 108
 
109
-  public function test_it_returns_empty_array_when_no_options_are_set()
110
-  {
109
+    public function test_it_returns_empty_array_when_no_options_are_set()
110
+    {
111 111
     $options = OptionBuilder::forFile()->build();
112 112
     $this->assertIsArray($options);
113 113
     $this->assertEmpty($options);
114
-  }
114
+    }
115 115
 
116 116
 }
Please login to merge, or discard this patch.
src/CacheStore/ArrayCacheStore.php 1 patch
Indentation   +207 added lines, -207 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,127 +138,127 @@  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 array $cacheKeys
155
-   * @param string $namespace
156
-   * @param string|int $ttl
157
-   * @return array
158
-   */
159
-  public function getMany(array $cacheKeys, string $namespace = '', string|int $ttl = 3600)
160
-  {
151
+    }
152
+
153
+    /**
154
+     * @param array $cacheKeys
155
+     * @param string $namespace
156
+     * @param string|int $ttl
157
+     * @return array
158
+     */
159
+    public function getMany(array $cacheKeys, string $namespace = '', string|int $ttl = 3600)
160
+    {
161 161
     $results = [];
162 162
     foreach ($cacheKeys as $cacheKey) {
163
-      $results[$cacheKey] = $this->getCache($cacheKey, $namespace, $ttl);
163
+        $results[$cacheKey] = $this->getCache($cacheKey, $namespace, $ttl);
164 164
     }
165 165
     return $results;
166
-  }
167
-
168
-  /**
169
-   * @param string $cacheKey
170
-   * @param string $namespace
171
-   * @return bool
172
-   */
173
-  public function has(string $cacheKey, string $namespace = '')
174
-  {
166
+    }
167
+
168
+    /**
169
+     * @param string $cacheKey
170
+     * @param string $namespace
171
+     * @return bool
172
+     */
173
+    public function has(string $cacheKey, string $namespace = '')
174
+    {
175 175
     $arrayStoreKey = $this->buildArrayKey($cacheKey, $namespace);
176 176
     return isset($this->arrayStore[$arrayStoreKey]) && time() < $this->arrayStore[$arrayStoreKey]['expirationTime'];
177
-  }
178
-
179
-  /**
180
-   * @param string $cacheKey
181
-   * @param int $amount
182
-   * @param string $namespace
183
-   * @return bool
184
-   */
185
-  public function increment(string $cacheKey, int $amount = 1, string $namespace = '')
186
-  {
177
+    }
178
+
179
+    /**
180
+     * @param string $cacheKey
181
+     * @param int $amount
182
+     * @param string $namespace
183
+     * @return bool
184
+     */
185
+    public function increment(string $cacheKey, int $amount = 1, string $namespace = '')
186
+    {
187 187
     $cacheData = $this->getCache($cacheKey, $namespace);
188 188
 
189 189
     if(!empty($cacheData) && is_numeric($cacheData)) {
190
-      $this->putCache($cacheKey, (int)($cacheData + $amount), $namespace);
191
-      $this->setMessage($this->getMessage(), $this->isSuccess());
192
-      return true;
190
+        $this->putCache($cacheKey, (int)($cacheData + $amount), $namespace);
191
+        $this->setMessage($this->getMessage(), $this->isSuccess());
192
+        return true;
193 193
     }
194 194
 
195 195
     return false;
196
-  }
196
+    }
197 197
 
198
-  /**
199
-   * @return boolean
200
-   */
201
-  public function isSuccess()
202
-  {
198
+    /**
199
+     * @return boolean
200
+     */
201
+    public function isSuccess()
202
+    {
203 203
     return $this->success;
204
-  }
204
+    }
205 205
 
206
-  /**
207
-   * @return string
208
-   */
209
-  public function getMessage()
210
-  {
206
+    /**
207
+     * @return string
208
+     */
209
+    public function getMessage()
210
+    {
211 211
     return $this->message;
212
-  }
213
-
214
-  /**
215
-   * @param string $cacheKey
216
-   * @param mixed $cacheData
217
-   * @param string $namespace
218
-   * @param int|string $ttl
219
-   * @return bool
220
-   */
221
-  public function putCache(string $cacheKey, mixed $cacheData, string $namespace = '', int|string $ttl = 3600)
222
-  {
212
+    }
213
+
214
+    /**
215
+     * @param string $cacheKey
216
+     * @param mixed $cacheData
217
+     * @param string $namespace
218
+     * @param int|string $ttl
219
+     * @return bool
220
+     */
221
+    public function putCache(string $cacheKey, mixed $cacheData, string $namespace = '', int|string $ttl = 3600)
222
+    {
223 223
     $arrayStoreKey = $this->buildArrayKey($cacheKey, $namespace);
224 224
 
225 225
     $this->arrayStore[$arrayStoreKey] = [
226
-      'cacheData' => serialize($cacheData),
227
-      'expirationTime' => time() + $ttl
226
+        'cacheData' => serialize($cacheData),
227
+        'expirationTime' => time() + $ttl
228 228
     ];
229 229
 
230 230
     $this->setMessage("Cache stored successfully", true);
231 231
     $this->logger->debug("{$this->getMessage()} from Array driver.");
232 232
     return true;
233
-  }
234
-
235
-  /**
236
-   * @param array $items
237
-   * @param string $namespace
238
-   * @param int $batchSize
239
-   * @return void
240
-   */
241
-  public function putMany(array $items, string $namespace = '', int $batchSize = 100)
242
-  {
233
+    }
234
+
235
+    /**
236
+     * @param array $items
237
+     * @param string $namespace
238
+     * @param int $batchSize
239
+     * @return void
240
+     */
241
+    public function putMany(array $items, string $namespace = '', int $batchSize = 100)
242
+    {
243 243
     $chunks = array_chunk($items, $batchSize, true);
244 244
 
245 245
     foreach ($chunks as $chunk) {
246
-      foreach ($chunk as $key => $data) {
247
-          $this->putCache($data['cacheKey'], $data['cacheData'], $namespace);
246
+        foreach ($chunk as $key => $data) {
247
+            $this->putCache($data['cacheKey'], $data['cacheData'], $namespace);
248
+        }
248 249
         }
249
-      }
250 250
     $this->setMessage("{$this->getMessage()}", $this->isSuccess());
251 251
     $this->logger->debug("{$this->getMessage()} from Array driver.");
252
-  }
253
-
254
-  /**
255
-   * @param string $cacheKey
256
-   * @param string|int $ttl
257
-   * @param string $namespace
258
-   * @return void
259
-   */
260
-  public function renewCache(string $cacheKey, int|string $ttl = 3600, string $namespace = '')
261
-  {
252
+    }
253
+
254
+    /**
255
+     * @param string $cacheKey
256
+     * @param string|int $ttl
257
+     * @param string $namespace
258
+     * @return void
259
+     */
260
+    public function renewCache(string $cacheKey, int|string $ttl = 3600, string $namespace = '')
261
+    {
262 262
     $arrayStoreKey = $this->buildArrayKey($cacheKey, $namespace);
263 263
 
264 264
     if (isset($this->arrayStore[$arrayStoreKey])) {
@@ -266,27 +266,27 @@  discard block
 block discarded – undo
266 266
         $this->arrayStore[$arrayStoreKey]['expirationTime'] = time() + $ttlSeconds;
267 267
         $this->setMessage("cacheKey: {$cacheKey} renewed successfully", true);
268 268
         $this->logger->debug("{$this->getMessage()} from array driver.");
269
-      }
270
-  }
271
-
272
-  /**
273
-   * @param string  $message
274
-   * @param boolean $success
275
-   * @return void
276
-   */
277
-  private function setMessage(string $message, bool $success)
278
-  {
269
+        }
270
+    }
271
+
272
+    /**
273
+     * @param string  $message
274
+     * @param boolean $success
275
+     * @return void
276
+     */
277
+    private function setMessage(string $message, bool $success)
278
+    {
279 279
     $this->message = $message;
280 280
     $this->success = $success;
281
-  }
282
-
283
-  /**
284
-   * @param mixed $data
285
-   * @param bool $serialize
286
-   * @return mixed
287
-   */
288
-  private function serialize(mixed $data, bool $serialize = true)
289
-  {
281
+    }
282
+
283
+    /**
284
+     * @param mixed $data
285
+     * @param bool $serialize
286
+     * @return mixed
287
+     */
288
+    private function serialize(mixed $data, bool $serialize = true)
289
+    {
290 290
     return $serialize ? serialize($data) : unserialize($data);
291
-  }
291
+    }
292 292
 }
Please login to merge, or discard this patch.