@@ -7,33 +7,33 @@ |
||
7 | 7 | class CacheFileException extends BaseException |
8 | 8 | { |
9 | 9 | |
10 | - /** @param string $before */ |
|
11 | - private static string $before = "<File Cache Store Exception>"; |
|
12 | - |
|
13 | - /** |
|
14 | - * @return void |
|
15 | - */ |
|
16 | - public static function create(string $message = "", int $code = 0, ?Exception $previous = null, array $details = []) |
|
17 | - { |
|
10 | + /** @param string $before */ |
|
11 | + private static string $before = "<File Cache Store Exception>"; |
|
12 | + |
|
13 | + /** |
|
14 | + * @return void |
|
15 | + */ |
|
16 | + public static function create(string $message = "", int $code = 0, ?Exception $previous = null, array $details = []) |
|
17 | + { |
|
18 | 18 | return new self(self::getBefore() . ": " .$message, $code, $previous, $details); |
19 | - } |
|
19 | + } |
|
20 | 20 | |
21 | 21 | |
22 | - /** |
|
23 | - * @return string |
|
24 | - */ |
|
25 | - public static function getBefore() |
|
26 | - { |
|
22 | + /** |
|
23 | + * @return string |
|
24 | + */ |
|
25 | + public static function getBefore() |
|
26 | + { |
|
27 | 27 | return self::$before; |
28 | - } |
|
28 | + } |
|
29 | 29 | |
30 | - /** |
|
31 | - * @return void |
|
32 | - */ |
|
33 | - public static function setBefore(string $text) |
|
34 | - { |
|
30 | + /** |
|
31 | + * @return void |
|
32 | + */ |
|
33 | + public static function setBefore(string $text) |
|
34 | + { |
|
35 | 35 | self::$before = $text; |
36 | - } |
|
36 | + } |
|
37 | 37 | |
38 | 38 | } |
39 | 39 |
@@ -17,7 +17,7 @@ |
||
17 | 17 | */ |
18 | 18 | public static function create(string $message = "", int $code = 0, ?Exception $previous = null, array $details = []) |
19 | 19 | { |
20 | - return new self(self::getBefore() . ": " .$message, $code, $previous, $details); |
|
20 | + return new self(self::getBefore() . ": " . $message, $code, $previous, $details); |
|
21 | 21 | } |
22 | 22 | |
23 | 23 |
@@ -48,10 +48,10 @@ discard block |
||
48 | 48 | } |
49 | 49 | |
50 | 50 | /** |
51 | - * @param string $cacheKey |
|
52 | - * @param string $namespace |
|
53 | - * @return mixed |
|
54 | - */ |
|
51 | + * @param string $cacheKey |
|
52 | + * @param string $namespace |
|
53 | + * @return mixed |
|
54 | + */ |
|
55 | 55 | public function retrieve(string $cacheKey, string $namespace = '') |
56 | 56 | { |
57 | 57 | $driver = $this->connection->getAttribute(PDO::ATTR_DRIVER_NAME); |
@@ -105,11 +105,11 @@ discard block |
||
105 | 105 | } |
106 | 106 | |
107 | 107 | /** |
108 | - * @param string $cacheKey |
|
109 | - * @param string|int $ttl |
|
110 | - * @param string $namespace |
|
111 | - * @return bool |
|
112 | - */ |
|
108 | + * @param string $cacheKey |
|
109 | + * @param string|int $ttl |
|
110 | + * @param string $namespace |
|
111 | + * @return bool |
|
112 | + */ |
|
113 | 113 | public function renew(string $cacheKey, string|int $ttl, string $namespace = '') |
114 | 114 | { |
115 | 115 | $currentTime = date('Y-m-d H:i:s'); |
@@ -163,9 +163,9 @@ discard block |
||
163 | 163 | } |
164 | 164 | |
165 | 165 | /** |
166 | - * @param string $driver |
|
167 | - * @return string |
|
168 | - */ |
|
166 | + * @param string $driver |
|
167 | + * @return string |
|
168 | + */ |
|
169 | 169 | private function getCurrentDateTime(string $driver) |
170 | 170 | { |
171 | 171 | return ($driver === 'sqlite') ? "DATETIME('now', 'localtime')" : "NOW()"; |
@@ -29,7 +29,7 @@ discard block |
||
29 | 29 | * @param string|int $ttl |
30 | 30 | * @return bool |
31 | 31 | */ |
32 | - public function store(string $cacheKey, mixed $cacheData, string $namespace, string|int $ttl = 3600) |
|
32 | + public function store(string $cacheKey, mixed $cacheData, string $namespace, string | int $ttl = 3600) |
|
33 | 33 | { |
34 | 34 | $expirationTime = date('Y-m-d H:i:s', time() + $ttl); |
35 | 35 | $createdAt = date('Y-m-d H:i:s'); |
@@ -110,7 +110,7 @@ discard block |
||
110 | 110 | * @param string $namespace |
111 | 111 | * @return bool |
112 | 112 | */ |
113 | - public function renew(string $cacheKey, string|int $ttl, string $namespace = '') |
|
113 | + public function renew(string $cacheKey, string | int $ttl, string $namespace = '') |
|
114 | 114 | { |
115 | 115 | $currentTime = date('Y-m-d H:i:s'); |
116 | 116 | |
@@ -130,7 +130,7 @@ discard block |
||
130 | 130 | SET expirationTime = DATE_ADD(expirationTime, INTERVAL ? SECOND) |
131 | 131 | WHERE cacheKey = ? AND cacheNamespace = ? AND expirationTime > ?" |
132 | 132 | ); |
133 | - $stmt->bindValue(1, (int) $ttl, PDO::PARAM_INT); |
|
133 | + $stmt->bindValue(1, (int)$ttl, PDO::PARAM_INT); |
|
134 | 134 | $stmt->bindValue(2, $cacheKey); |
135 | 135 | $stmt->bindValue(3, $namespace); |
136 | 136 | $stmt->bindValue(4, $currentTime); |
@@ -23,15 +23,15 @@ |
||
23 | 23 | echo "Cache Found: "; |
24 | 24 | print_r($Cacheer->getCache($cacheKey)); |
25 | 25 | } else { |
26 | - echo $Cacheer->getMessage(); |
|
26 | + echo $Cacheer->getMessage(); |
|
27 | 27 | } |
28 | 28 | |
29 | 29 | // Renovando os dados do cache |
30 | 30 | $Cacheer->renewCache($cacheKey, 3600); |
31 | 31 | |
32 | 32 | if($Cacheer->isSuccess()){ |
33 | - echo $Cacheer->getMessage() . PHP_EOL; |
|
33 | + echo $Cacheer->getMessage() . PHP_EOL; |
|
34 | 34 | } else { |
35 | - echo $Cacheer->getMessage() . PHP_EOL; |
|
35 | + echo $Cacheer->getMessage() . PHP_EOL; |
|
36 | 36 | |
37 | 37 | } |
38 | 38 | \ No newline at end of file |
@@ -19,7 +19,7 @@ discard block |
||
19 | 19 | $Cacheer->putCache($cacheKey, $userProfile, ttl: 300); |
20 | 20 | |
21 | 21 | // Recuperando dados do cache |
22 | -if($Cacheer->isSuccess()){ |
|
22 | +if ($Cacheer->isSuccess()) { |
|
23 | 23 | echo "Cache Found: "; |
24 | 24 | print_r($Cacheer->getCache($cacheKey)); |
25 | 25 | } else { |
@@ -29,7 +29,7 @@ discard block |
||
29 | 29 | // Renovando os dados do cache |
30 | 30 | $Cacheer->renewCache($cacheKey, 3600); |
31 | 31 | |
32 | -if($Cacheer->isSuccess()){ |
|
32 | +if ($Cacheer->isSuccess()) { |
|
33 | 33 | echo $Cacheer->getMessage() . PHP_EOL; |
34 | 34 | } else { |
35 | 35 | echo $Cacheer->getMessage() . PHP_EOL; |
@@ -29,7 +29,7 @@ discard block |
||
29 | 29 | echo "Cache Found: "; |
30 | 30 | print_r($Cacheer->getCache($cacheKey)); |
31 | 31 | } else { |
32 | - echo $Cacheer->getMessage(); |
|
32 | + echo $Cacheer->getMessage(); |
|
33 | 33 | } |
34 | 34 | |
35 | 35 | |
@@ -40,6 +40,6 @@ discard block |
||
40 | 40 | echo $Cacheer->getMessage() . PHP_EOL; |
41 | 41 | print_r($Cacheer->getCache($cacheKey)); |
42 | 42 | } else { |
43 | - echo $Cacheer->getMessage(); |
|
43 | + echo $Cacheer->getMessage(); |
|
44 | 44 | } |
45 | 45 |
@@ -25,7 +25,7 @@ discard block |
||
25 | 25 | $Cacheer->putCache($cacheKey, $userProfile); |
26 | 26 | |
27 | 27 | // Recuperando dados do cache |
28 | -if($Cacheer->isSuccess()){ |
|
28 | +if ($Cacheer->isSuccess()) { |
|
29 | 29 | echo "Cache Found: "; |
30 | 30 | print_r($Cacheer->getCache($cacheKey)); |
31 | 31 | } else { |
@@ -36,7 +36,7 @@ discard block |
||
36 | 36 | // Mesclando os dados |
37 | 37 | $Cacheer->appendCache($cacheKey, $userProfile02); |
38 | 38 | |
39 | -if($Cacheer->isSuccess()){ |
|
39 | +if ($Cacheer->isSuccess()) { |
|
40 | 40 | echo $Cacheer->getMessage() . PHP_EOL; |
41 | 41 | print_r($Cacheer->getCache($cacheKey)); |
42 | 42 | } else { |
@@ -34,8 +34,8 @@ |
||
34 | 34 | } |
35 | 35 | |
36 | 36 | /** |
37 | - * @return void |
|
38 | - */ |
|
37 | + * @return void |
|
38 | + */ |
|
39 | 39 | public static function copyEnv() |
40 | 40 | { |
41 | 41 | $rootDir = self::getRootPath(); |
@@ -7,26 +7,26 @@ discard block |
||
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_diretory() |
|
29 | - { |
|
28 | + public function test_it_can_set_cache_diretory() |
|
29 | + { |
|
30 | 30 | $cacheDir = __DIR__ . "/cache"; |
31 | 31 | |
32 | 32 | $options = OptionBuilder::forFile() |
@@ -35,23 +35,23 @@ discard block |
||
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 |
||
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 |
||
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 | } |
@@ -7,27 +7,27 @@ discard block |
||
7 | 7 | class RedisTest 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 |
||
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 |
||
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 |
||
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 |
||
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 |
||
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 |
||
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 |
||
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 |
||
193 | 193 | $this->assertEmpty($this->cache->getCache($cacheKey)); |
194 | 194 | } |
195 | 195 | |
196 | - public function testFlushCacheDataFromDatabase() |
|
196 | + public function testFlushCacheDataFromDatabase() |
|
197 | 197 | { |
198 | 198 | $key1 = 'test_key1'; |
199 | 199 | $data1 = 'test_data1'; |
@@ -212,8 +212,8 @@ discard block |
||
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 |
||
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 |
||
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,6 +256,6 @@ discard block |
||
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 | 261 | } |
@@ -11,10 +11,10 @@ |
||
11 | 11 | */ |
12 | 12 | class OptionBuilder |
13 | 13 | { |
14 | - /** |
|
15 | - * @return FileOptionBuilder |
|
16 | - */ |
|
17 | - public static function forFile() { |
|
14 | + /** |
|
15 | + * @return FileOptionBuilder |
|
16 | + */ |
|
17 | + public static function forFile() { |
|
18 | 18 | return new FileOptionBuilder(); |
19 | - } |
|
19 | + } |
|
20 | 20 | } |
@@ -11,103 +11,103 @@ |
||
11 | 11 | */ |
12 | 12 | class FileOptionBuilder |
13 | 13 | { |
14 | - /** @param null|string $cacheDir */ |
|
15 | - private ?string $cacheDir = null; |
|
14 | + /** @param null|string $cacheDir */ |
|
15 | + private ?string $cacheDir = null; |
|
16 | 16 | |
17 | - /** @param null|string $expirationTime */ |
|
18 | - private ?string $expirationTime = null; |
|
17 | + /** @param null|string $expirationTime */ |
|
18 | + private ?string $expirationTime = null; |
|
19 | 19 | |
20 | - /** @param null|string $flushAfter */ |
|
21 | - private ?string $flushAfter = null; |
|
20 | + /** @param null|string $flushAfter */ |
|
21 | + private ?string $flushAfter = null; |
|
22 | 22 | |
23 | - /** @param array $options */ |
|
24 | - private array $options = []; |
|
23 | + /** @param array $options */ |
|
24 | + private array $options = []; |
|
25 | 25 | |
26 | - /** |
|
27 | - * @param string $cacheDir |
|
28 | - * @return $this |
|
29 | - */ |
|
30 | - public function dir(string $cacheDir) |
|
31 | - { |
|
26 | + /** |
|
27 | + * @param string $cacheDir |
|
28 | + * @return $this |
|
29 | + */ |
|
30 | + public function dir(string $cacheDir) |
|
31 | + { |
|
32 | 32 | $this->cacheDir = $cacheDir; |
33 | 33 | return $this; |
34 | - } |
|
34 | + } |
|
35 | 35 | |
36 | - /** |
|
37 | - * @param ?string $expirationTime |
|
38 | - * @return $this|TimeBuilder |
|
39 | - */ |
|
40 | - public function expirationTime(?string $expirationTime = null) |
|
41 | - { |
|
36 | + /** |
|
37 | + * @param ?string $expirationTime |
|
38 | + * @return $this|TimeBuilder |
|
39 | + */ |
|
40 | + public function expirationTime(?string $expirationTime = null) |
|
41 | + { |
|
42 | 42 | |
43 | 43 | if (!is_null($expirationTime)) { |
44 | - $this->expirationTime = $expirationTime; |
|
45 | - return $this; |
|
44 | + $this->expirationTime = $expirationTime; |
|
45 | + return $this; |
|
46 | 46 | } |
47 | 47 | |
48 | 48 | return new TimeBuilder(function ($formattedTime){ |
49 | - $this->expirationTime = $formattedTime; |
|
49 | + $this->expirationTime = $formattedTime; |
|
50 | 50 | }, $this); |
51 | - } |
|
51 | + } |
|
52 | 52 | |
53 | - /** |
|
54 | - * @param ?string $flushAfter |
|
55 | - * @return $this|TimeBuilder |
|
56 | - */ |
|
57 | - public function flushAfter(?string $flushAfter = null) |
|
58 | - { |
|
53 | + /** |
|
54 | + * @param ?string $flushAfter |
|
55 | + * @return $this|TimeBuilder |
|
56 | + */ |
|
57 | + public function flushAfter(?string $flushAfter = null) |
|
58 | + { |
|
59 | 59 | |
60 | 60 | if (!is_null($flushAfter)) { |
61 | - $this->flushAfter = mb_strtolower($flushAfter, 'UTF-8'); |
|
62 | - return $this; |
|
61 | + $this->flushAfter = mb_strtolower($flushAfter, 'UTF-8'); |
|
62 | + return $this; |
|
63 | 63 | } |
64 | 64 | |
65 | 65 | return new TimeBuilder(function ($formattedTime){ |
66 | - $this->flushAfter = $formattedTime; |
|
66 | + $this->flushAfter = $formattedTime; |
|
67 | 67 | }, $this); |
68 | - } |
|
68 | + } |
|
69 | 69 | |
70 | - /** |
|
71 | - * @return array |
|
72 | - */ |
|
73 | - public function build() |
|
74 | - { |
|
70 | + /** |
|
71 | + * @return array |
|
72 | + */ |
|
73 | + public function build() |
|
74 | + { |
|
75 | 75 | return $this->validated(); |
76 | - } |
|
76 | + } |
|
77 | 77 | |
78 | - /** |
|
79 | - * @return array |
|
80 | - */ |
|
81 | - private function validated() |
|
82 | - { |
|
78 | + /** |
|
79 | + * @return array |
|
80 | + */ |
|
81 | + private function validated() |
|
82 | + { |
|
83 | 83 | foreach ($this->properties() as $key => $value) { |
84 | 84 | if ($this->isValidAndNotNull($value)) { |
85 | 85 | $this->options[$key] = $value; |
86 | 86 | } |
87 | 87 | } |
88 | 88 | return $this->options; |
89 | - } |
|
90 | - |
|
91 | - /** |
|
92 | - * @param mixed $data |
|
93 | - * @return bool |
|
94 | - */ |
|
95 | - private function isValidAndNotNull(mixed $data) |
|
96 | - { |
|
89 | + } |
|
90 | + |
|
91 | + /** |
|
92 | + * @param mixed $data |
|
93 | + * @return bool |
|
94 | + */ |
|
95 | + private function isValidAndNotNull(mixed $data) |
|
96 | + { |
|
97 | 97 | return !empty($data) ? true : false; |
98 | - } |
|
98 | + } |
|
99 | 99 | |
100 | - /** |
|
101 | - * @return array |
|
102 | - */ |
|
103 | - private function properties() |
|
104 | - { |
|
100 | + /** |
|
101 | + * @return array |
|
102 | + */ |
|
103 | + private function properties() |
|
104 | + { |
|
105 | 105 | $properties = [ |
106 | - 'cacheDir' => $this->cacheDir, |
|
107 | - 'expirationTime' => $this->expirationTime, |
|
108 | - 'flushAfter' => $this->flushAfter |
|
106 | + 'cacheDir' => $this->cacheDir, |
|
107 | + 'expirationTime' => $this->expirationTime, |
|
108 | + 'flushAfter' => $this->flushAfter |
|
109 | 109 | ]; |
110 | 110 | |
111 | 111 | return $properties; |
112 | - } |
|
112 | + } |
|
113 | 113 | } |
@@ -45,7 +45,7 @@ discard block |
||
45 | 45 | return $this; |
46 | 46 | } |
47 | 47 | |
48 | - return new TimeBuilder(function ($formattedTime){ |
|
48 | + return new TimeBuilder(function($formattedTime) { |
|
49 | 49 | $this->expirationTime = $formattedTime; |
50 | 50 | }, $this); |
51 | 51 | } |
@@ -62,7 +62,7 @@ discard block |
||
62 | 62 | return $this; |
63 | 63 | } |
64 | 64 | |
65 | - return new TimeBuilder(function ($formattedTime){ |
|
65 | + return new TimeBuilder(function($formattedTime) { |
|
66 | 66 | $this->flushAfter = $formattedTime; |
67 | 67 | }, $this); |
68 | 68 | } |