Passed
Pull Request — main (#32)
by Sílvio
06:34 queued 03:50
created
src/CacheStore/CacheManager/RedisCacheManager.php 1 patch
Indentation   +22 added lines, -22 removed lines patch added patch discarded remove patch
@@ -14,38 +14,38 @@
 block discarded – undo
14 14
 class RedisCacheManager
15 15
 {
16 16
 
17
-  /** @var Predis\Client */
18
-  private static $redis;
17
+    /** @var Predis\Client */
18
+    private static $redis;
19 19
 
20
-  /** @param string $namespace */
21
-  private static $namespace;
20
+    /** @param string $namespace */
21
+    private static $namespace;
22 22
 
23
-  /**
24
-  * @return Client
25
-  */
26
-  public static function connect()
27
-  {
23
+    /**
24
+     * @return Client
25
+     */
26
+    public static function connect()
27
+    {
28 28
     Autoloader::register();
29 29
     self::$redis = new Client([
30
-      'scheme' => 'tcp',
31
-      'host' => REDIS_CONNECTION_CONFIG['REDIS_HOST'],
32
-      'port' => REDIS_CONNECTION_CONFIG['REDIS_PORT'],
33
-      'password' => REDIS_CONNECTION_CONFIG['REDIS_PASSWORD'],
34
-      'database' => 0
30
+        'scheme' => 'tcp',
31
+        'host' => REDIS_CONNECTION_CONFIG['REDIS_HOST'],
32
+        'port' => REDIS_CONNECTION_CONFIG['REDIS_PORT'],
33
+        'password' => REDIS_CONNECTION_CONFIG['REDIS_PASSWORD'],
34
+        'database' => 0
35 35
     ]);
36 36
     self::auth();
37 37
     self::$namespace = REDIS_CONNECTION_CONFIG['REDIS_NAMESPACE'] ?? 'Cache';
38 38
     return self::$redis;
39
-  }
39
+    }
40 40
 
41
-  /**
42
-  * @return void
43
-  */
44
-  private static function auth()
45
-  {
41
+    /**
42
+     * @return void
43
+     */
44
+    private static function auth()
45
+    {
46 46
     if(is_string(REDIS_CONNECTION_CONFIG['REDIS_PASSWORD']) && REDIS_CONNECTION_CONFIG['REDIS_PASSWORD'] !== '') {
47
-      self::$redis->auth(REDIS_CONNECTION_CONFIG['REDIS_PASSWORD']);
47
+        self::$redis->auth(REDIS_CONNECTION_CONFIG['REDIS_PASSWORD']);
48
+    }
48 49
     }
49
-  }
50 50
 
51 51
 }
Please login to merge, or discard this patch.
src/Support/TimeBuilder.php 1 patch
Indentation   +68 added lines, -68 removed lines patch added patch discarded remove patch
@@ -13,91 +13,91 @@
 block discarded – undo
13 13
 class TimeBuilder
14 14
 {
15 15
 
16
-  /** @param string $unit */
17
-  private string $unit;
16
+    /** @param string $unit */
17
+    private string $unit;
18 18
 
19
-  /** @param int $value */
20
-  private int $value;
19
+    /** @param int $value */
20
+    private int $value;
21 21
 
22
-  /** @param Closure $callback */
23
-  private Closure $callback;
22
+    /** @param Closure $callback */
23
+    private Closure $callback;
24 24
 
25
-  /** @param FileOptionBuilder */
26
-  private $builder = null;
25
+    /** @param FileOptionBuilder */
26
+    private $builder = null;
27 27
 
28
-  public function __construct(Closure $callback, $builder)
29
-  {
28
+    public function __construct(Closure $callback, $builder)
29
+    {
30 30
     $this->callback = $callback;
31 31
     $this->builder = $builder;
32
-  }
33
-
34
-  /**
35
-  * @param int $value
36
-  * @return FileOptionBuilder|mixed
37
-  */
38
-  public function second(int $value) 
39
-  {
32
+    }
33
+
34
+    /**
35
+     * @param int $value
36
+     * @return FileOptionBuilder|mixed
37
+     */
38
+    public function second(int $value) 
39
+    {
40 40
     return $this->setTime($value, "seconds");
41
-  }
42
-
43
-  /**
44
-  * @param int $value
45
-  * @return FileOptionBuilder|mixed
46
-  */
47
-  public function minute(int $value) 
48
-  {
41
+    }
42
+
43
+    /**
44
+     * @param int $value
45
+     * @return FileOptionBuilder|mixed
46
+     */
47
+    public function minute(int $value) 
48
+    {
49 49
     return $this->setTime($value, "minutes");
50
-  }
51
-
52
-  /**
53
-  * @param int $value
54
-  * @return FileOptionBuilder|mixed
55
-  */
56
-  public function hour(int $value) 
57
-  {
50
+    }
51
+
52
+    /**
53
+     * @param int $value
54
+     * @return FileOptionBuilder|mixed
55
+     */
56
+    public function hour(int $value) 
57
+    {
58 58
     return $this->setTime($value, "hours");
59
-  }
60
-
61
-  /**
62
-  * @param int $value
63
-  * @return FileOptionBuilder|mixed
64
-  */
65
-  public function day(int $value) 
66
-  {
59
+    }
60
+
61
+    /**
62
+     * @param int $value
63
+     * @return FileOptionBuilder|mixed
64
+     */
65
+    public function day(int $value) 
66
+    {
67 67
     return $this->setTime($value, "days");
68
-  }
69
-
70
-  /**
71
-  * @param int $value
72
-  * @return FileOptionBuilder|mixed
73
-  */
74
-  public function week(int $value) 
75
-  {
68
+    }
69
+
70
+    /**
71
+     * @param int $value
72
+     * @return FileOptionBuilder|mixed
73
+     */
74
+    public function week(int $value) 
75
+    {
76 76
     return $this->setTime($value, "weeks");
77
-  }
78
-
79
-  /**
80
-  * @param int $value
81
-  * @return FileOptionBuilder|mixed
82
-  */
83
-  public function month(int $value) 
84
-  {
77
+    }
78
+
79
+    /**
80
+     * @param int $value
81
+     * @return FileOptionBuilder|mixed
82
+     */
83
+    public function month(int $value) 
84
+    {
85 85
     return $this->setTime($value, "months");
86
-  }
86
+    }
87 87
   
88 88
 
89
-  /**
90
-  * @param int $value
91
-  * @param string $unit
92
-  * @return FileOptionBuilder
93
-  */
94
-  private function setTime(int $value, string $unit) 
95
-  {
89
+    /**
90
+     * @param int $value
91
+     * @param string $unit
92
+     * @return FileOptionBuilder
93
+     */
94
+    private function setTime(int $value, string $unit) 
95
+    {
96 96
 
97 97
     $this->value = $value;
98 98
     $this->unit = $unit;
99
-   ($this->callback)("{$value} {$unit}");
99
+    ($this->callback)("{$value} {$unit}");
100 100
     return $this->builder;
101
-  }
101
+    }
102 102
 
103 103
 }
Please login to merge, or discard this patch.
tests/Unit/RedisCacheStoreTest.php 1 patch
Indentation   +43 added lines, -43 removed lines patch added patch discarded remove patch
@@ -7,27 +7,27 @@  discard block
 block discarded – undo
7 7
 class RedisCacheStoreTest extends TestCase
8 8
 {
9 9
 
10
-  /** @var Cacheer */
11
-  private $cache;
10
+    /** @var Cacheer */
11
+    private $cache;
12 12
 
13
-  protected function setUp(): void
14
-  {
13
+    protected function setUp(): void
14
+    {
15 15
     $this->cache = new Cacheer();
16 16
     $this->cache->setDriver()->useRedisDriver();
17
-  }
17
+    }
18 18
 
19
-  protected function tearDown(): void
20
-  {
19
+    protected function tearDown(): void
20
+    {
21 21
     $this->cache->flushCache();
22
-  }
22
+    }
23 23
 
24
-  public function testUsingRedisDriverSetsProperInstance()
25
-  {
24
+    public function testUsingRedisDriverSetsProperInstance()
25
+    {
26 26
     $this->assertInstanceOf(RedisCacheStore::class, $this->cache->cacheStore);
27
-  }
27
+    }
28 28
 
29
-  public function testPutCacheInRedis()
30
-  {
29
+    public function testPutCacheInRedis()
30
+    {
31 31
     $cacheKey = 'test_key';
32 32
     $cacheData = ['name' => 'Sílvio Silva', 'role' => 'Developer'];
33 33
 
@@ -37,10 +37,10 @@  discard block
 block discarded – undo
37 37
     $this->assertNotEmpty($this->cache->getCache($cacheKey));
38 38
     $this->assertEquals($cacheData, $this->cache->getCache($cacheKey));
39 39
 
40
-  }
40
+    }
41 41
 
42
-  public function testGetCacheFromRedis()
43
-  {
42
+    public function testGetCacheFromRedis()
43
+    {
44 44
     $cacheKey = 'test_key';
45 45
     $cacheData = ['name' => 'Sílvio Silva', 'role' => 'Developer'];
46 46
 
@@ -51,10 +51,10 @@  discard block
 block discarded – undo
51 51
     $data = $this->cache->getCache($cacheKey);
52 52
     $this->assertNotEmpty($data);
53 53
     $this->assertEquals($cacheData, $data);
54
-  }
54
+    }
55 55
 
56
-  public function testExpiredCacheInRedis()
57
-  {
56
+    public function testExpiredCacheInRedis()
57
+    {
58 58
     $cacheKey = 'expired_key';
59 59
     $cacheData = ['name' => 'Expired User', 'email' => '[email protected]'];
60 60
 
@@ -64,10 +64,10 @@  discard block
 block discarded – undo
64 64
     $this->assertEquals("Cache stored successfully", $this->cache->getMessage());
65 65
     $this->assertEmpty($this->cache->getCache($cacheKey));
66 66
     $this->assertFalse($this->cache->isSuccess());
67
-  }
67
+    }
68 68
 
69
-  public function testOverwriteExistingCacheInRedis()
70
-  {
69
+    public function testOverwriteExistingCacheInRedis()
70
+    {
71 71
     $cacheKey = 'overwrite_key';
72 72
     $initialCacheData = ['name' => 'Initial Data', 'email' => '[email protected]'];
73 73
     $newCacheData = ['name' => 'New Data', 'email' => '[email protected]'];
@@ -78,11 +78,11 @@  discard block
 block discarded – undo
78 78
     $this->cache->appendCache($cacheKey, $newCacheData);
79 79
     $this->assertEquals("Cache appended successfully", $this->cache->getMessage());
80 80
     $this->assertEquals($newCacheData, $this->cache->getCache($cacheKey));
81
-  }
81
+    }
82 82
 
83
-  public function testPutManyCacheItemsInRedis()
84
-  {
85
-     $items = [
83
+    public function testPutManyCacheItemsInRedis()
84
+    {
85
+        $items = [
86 86
             [
87 87
                 'cacheKey' => 'user_1_profile',
88 88
                 'cacheData' => [
@@ -107,9 +107,9 @@  discard block
 block discarded – undo
107 107
     foreach ($items as $item) {
108 108
             $this->assertEquals($item['cacheData'], $this->cache->getCache($item['cacheKey']));
109 109
         }
110
-  }
110
+    }
111 111
 
112
-      public function testAppendCacheWithNamespaceInRedis()
112
+        public function testAppendCacheWithNamespaceInRedis()
113 113
     {
114 114
         $cacheKey = 'test_append_key_ns';
115 115
         $namespace = 'test_namespace';
@@ -132,7 +132,7 @@  discard block
 block discarded – undo
132 132
         $this->assertEquals($expectedData, $cachedData);
133 133
     }
134 134
 
135
-      public function testDataOutputShouldBeOfTypeArray()
135
+        public function testDataOutputShouldBeOfTypeArray()
136 136
     {
137 137
 
138 138
         $this->cache->useFormatter();
@@ -178,7 +178,7 @@  discard block
 block discarded – undo
178 178
         $this->assertJson($cacheOutput);
179 179
     }
180 180
 
181
-      public function testClearCacheDataFromRedis()
181
+        public function testClearCacheDataFromRedis()
182 182
     {
183 183
         $cacheKey = 'test_key';
184 184
         $data = 'test_data';
@@ -193,7 +193,7 @@  discard block
 block discarded – undo
193 193
         $this->assertEmpty($this->cache->getCache($cacheKey));
194 194
     }
195 195
 
196
-  public function testFlushCacheDataFromRedis()
196
+    public function testFlushCacheDataFromRedis()
197 197
     {
198 198
         $key1 = 'test_key1';
199 199
         $data1 = 'test_data1';
@@ -212,8 +212,8 @@  discard block
 block discarded – undo
212 212
         $this->assertEquals("Cache flushed successfully", $this->cache->getMessage());
213 213
     }
214 214
 
215
-  public function testHasCacheFromRedis()
216
-  {
215
+    public function testHasCacheFromRedis()
216
+    {
217 217
     $cacheKey = 'test_key';
218 218
     $cacheData = ['name' => 'Sílvio Silva', 'role' => 'Developer'];
219 219
 
@@ -221,10 +221,10 @@  discard block
 block discarded – undo
221 221
 
222 222
     $this->assertEquals("Cache stored successfully", $this->cache->getMessage());
223 223
     $this->assertTrue($this->cache->isSuccess());
224
-  }
224
+    }
225 225
 
226
-  public function testRenewCacheFromRedis()
227
-  {
226
+    public function testRenewCacheFromRedis()
227
+    {
228 228
     $cacheKey = 'expired_key';
229 229
     $cacheData = ['name' => 'Expired User', 'email' => '[email protected]'];
230 230
 
@@ -239,10 +239,10 @@  discard block
 block discarded – undo
239 239
     $this->cache->renewCache($cacheKey, 7200);
240 240
     $this->assertTrue($this->cache->isSuccess());
241 241
     $this->assertNotEmpty($this->cache->getCache($cacheKey));
242
-  }
242
+    }
243 243
 
244 244
     public function testRenewCacheWithNamespaceFromRedis()
245
-  {
245
+    {
246 246
     $cacheKey = 'expired_key';
247 247
     $namespace = 'expired_namespace';
248 248
     $cacheData = ['name' => 'Expired User', 'email' => '[email protected]'];
@@ -256,9 +256,9 @@  discard block
 block discarded – undo
256 256
     $this->cache->renewCache($cacheKey, 7200, $namespace);
257 257
     $this->assertTrue($this->cache->isSuccess());
258 258
     $this->assertNotEmpty($this->cache->getCache($cacheKey, $namespace));
259
-  }
259
+    }
260 260
 
261
-  public function test_remember_saves_and_recover_values() 
261
+    public function test_remember_saves_and_recover_values() 
262 262
     {
263 263
         $this->cache->flushCache();
264 264
 
@@ -293,7 +293,7 @@  discard block
 block discarded – undo
293 293
     }
294 294
 
295 295
 
296
-      public function test_get_and_forget()
296
+        public function test_get_and_forget()
297 297
     {
298 298
         $cacheKey = 'cache_key_test';
299 299
         $this->cache->putCache($cacheKey, 10);
@@ -314,7 +314,7 @@  discard block
 block discarded – undo
314 314
         $this->assertNull($noCacheData);
315 315
     }
316 316
 
317
-      public function test_store_if_not_present_with_add_function()
317
+        public function test_store_if_not_present_with_add_function()
318 318
     {
319 319
         $existentKey = 'cache_key_test';
320 320
 
@@ -338,7 +338,7 @@  discard block
 block discarded – undo
338 338
 
339 339
     }
340 340
 
341
-      public function test_increment_function() {
341
+        public function test_increment_function() {
342 342
 
343 343
         $cacheKey = 'test_increment';
344 344
         $cacheData = 2025;
Please login to merge, or discard this patch.
src/Core/ConnectionFactory.php 1 patch
Indentation   +3 added lines, -3 removed lines patch added patch discarded remove patch
@@ -15,9 +15,9 @@
 block discarded – undo
15 15
 {
16 16
 
17 17
     /**
18
-      * @param array|null $database
19
-      * @return PDO|null
20
-    */
18
+     * @param array|null $database
19
+     * @return PDO|null
20
+     */
21 21
     public static function createConnection(?array $database = null)
22 22
     {
23 23
         $dbConf = $database ?? CACHEER_DATABASE_CONFIG[Connect::getConnection()];
Please login to merge, or discard this patch.
src/Core/Connect.php 1 patch
Indentation   +10 added lines, -10 removed lines patch added patch discarded remove patch
@@ -18,9 +18,9 @@  discard block
 block discarded – undo
18 18
 
19 19
 
20 20
     /**
21
-    * @param array|null $database
22
-    * @return PDO|null
23
-    */
21
+     * @param array|null $database
22
+     * @return PDO|null
23
+     */
24 24
     public static function getInstance(?array $database = null)
25 25
     {
26 26
         $pdo = ConnectionFactory::createConnection($database);
@@ -31,9 +31,9 @@  discard block
 block discarded – undo
31 31
     }
32 32
 
33 33
     /**
34
-    * @param string $connection
35
-    * @return void
36
-    */
34
+     * @param string $connection
35
+     * @return void
36
+     */
37 37
     public static function setConnection(string $connection)
38 38
     {
39 39
         $drivers = ['mysql', 'sqlite', 'pgsql'];
@@ -44,16 +44,16 @@  discard block
 block discarded – undo
44 44
     }
45 45
 
46 46
     /**
47
-    * @return string
48
-    */
47
+     * @return string
48
+     */
49 49
     public static function getConnection()
50 50
     {
51 51
         return self::$connection;
52 52
     }
53 53
 
54 54
     /**
55
-    * @return PDOException|null
56
-    */
55
+     * @return PDOException|null
56
+     */
57 57
     public static function getError()
58 58
     {
59 59
         return self::$error;
Please login to merge, or discard this patch.
src/Config/Option/Builder/OptionBuilder.php 1 patch
Indentation   +6 added lines, -6 removed lines patch added patch discarded remove patch
@@ -11,11 +11,11 @@
 block discarded – undo
11 11
  */
12 12
 class OptionBuilder
13 13
 {
14
-  /**
15
-  * @return FileOptionBuilder
16
-  */
17
-  public static function forFile() 
18
-  {
14
+    /**
15
+     * @return FileOptionBuilder
16
+     */
17
+    public static function forFile() 
18
+    {
19 19
     return new FileOptionBuilder();
20
-  }
20
+    }
21 21
 }
Please login to merge, or discard this patch.
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/Helpers/CacheRedisHelper.php 1 patch
Indentation   +18 added lines, -18 removed lines patch added patch discarded remove patch
@@ -13,20 +13,20 @@  discard block
 block discarded – undo
13 13
 class CacheRedisHelper
14 14
 {
15 15
 
16
-  /**
17
-  * @param mixed $data
18
-  * @param bool  $serialize
19
-  * @return mixed
20
-  */
21
-  public static function serialize(mixed $data, bool $serialize = true)
22
-  {
16
+    /**
17
+     * @param mixed $data
18
+     * @param bool  $serialize
19
+     * @return mixed
20
+     */
21
+    public static function serialize(mixed $data, bool $serialize = true)
22
+    {
23 23
     if($serialize) {
24
-      return serialize($data);
24
+        return serialize($data);
25 25
     }
26 26
 
27 27
     return unserialize($data);
28 28
 
29
-  }
29
+    }
30 30
 
31 31
     /**
32 32
      * @param array $item
@@ -49,15 +49,15 @@  discard block
 block discarded – undo
49 49
         return CacheerHelper::mergeCacheData($cacheData);
50 50
     }
51 51
 
52
-  /**
53
-    * @param mixed $currentCacheData
54
-    * @param mixed $cacheData
55
-    * @return array
56
-    */
57
-  public static function arrayIdentifier(mixed $currentCacheData, mixed $cacheData)
58
-  {
59
-      return CacheerHelper::arrayIdentifier($currentCacheData, $cacheData);
60
-  }
52
+    /**
53
+     * @param mixed $currentCacheData
54
+     * @param mixed $cacheData
55
+     * @return array
56
+     */
57
+    public static function arrayIdentifier(mixed $currentCacheData, mixed $cacheData)
58
+    {
59
+        return CacheerHelper::arrayIdentifier($currentCacheData, $cacheData);
60
+    }
61 61
 
62 62
 }
63 63
 
Please login to merge, or discard this patch.