@@ -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 | } |
@@ -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 | } |
@@ -13,91 +13,91 @@ |
||
| 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 | } |
@@ -55,7 +55,7 @@ discard block |
||
| 55 | 55 | * @param string|int $ttl |
| 56 | 56 | * @return CacheDataFormatter|mixed |
| 57 | 57 | */ |
| 58 | - public function getCache(string $cacheKey, string $namespace = '', string|int $ttl = 3600) |
|
| 58 | + public function getCache(string $cacheKey, string $namespace = '', string | int $ttl = 3600) |
|
| 59 | 59 | { |
| 60 | 60 | $cacheData = $this->cacheStore->getCache($cacheKey, $namespace, $ttl); |
| 61 | 61 | $this->setMessage($this->cacheStore->getMessage(), $this->cacheStore->isSuccess()); |
@@ -69,7 +69,7 @@ discard block |
||
| 69 | 69 | * @param string|int $ttl |
| 70 | 70 | * @return void |
| 71 | 71 | */ |
| 72 | - public function putCache(string $cacheKey, mixed $cacheData, string $namespace = '', string|int $ttl = 3600) |
|
| 72 | + public function putCache(string $cacheKey, mixed $cacheData, string $namespace = '', string | int $ttl = 3600) |
|
| 73 | 73 | { |
| 74 | 74 | $this->cacheStore->putCache($cacheKey, $cacheData, $namespace, $ttl); |
| 75 | 75 | $this->setMessage($this->cacheStore->getMessage(), $this->cacheStore->isSuccess()); |
@@ -115,7 +115,7 @@ discard block |
||
| 115 | 115 | * @param string $namespace |
| 116 | 116 | * @return mixed |
| 117 | 117 | */ |
| 118 | - public function renewCache(string $cacheKey, string|int $ttl = 3600, string $namespace = '') |
|
| 118 | + public function renewCache(string $cacheKey, string | int $ttl = 3600, string $namespace = '') |
|
| 119 | 119 | { |
| 120 | 120 | $renewedCache = $this->cacheStore->renewCache($cacheKey, $ttl, $namespace); |
| 121 | 121 | |
@@ -138,7 +138,7 @@ discard block |
||
| 138 | 138 | { |
| 139 | 139 | $cacheData = $this->getCache($cacheKey, $namespace); |
| 140 | 140 | |
| 141 | - if(!empty($cacheData) && is_numeric($cacheData)) { |
|
| 141 | + if (!empty($cacheData) && is_numeric($cacheData)) { |
|
| 142 | 142 | $this->putCache($cacheKey, (int)($cacheData + $amount), $namespace); |
| 143 | 143 | $this->setMessage($this->getMessage(), $this->isSuccess()); |
| 144 | 144 | return true; |
@@ -174,12 +174,12 @@ discard block |
||
| 174 | 174 | * @param Closure $callback |
| 175 | 175 | * @return mixed |
| 176 | 176 | */ |
| 177 | - public function remember(string $cacheKey, int|string $ttl, Closure $callback) |
|
| 177 | + public function remember(string $cacheKey, int | string $ttl, Closure $callback) |
|
| 178 | 178 | { |
| 179 | 179 | $isCache = $this->getCache($cacheKey); |
| 180 | 180 | |
| 181 | 181 | |
| 182 | - if(!empty($isCache)) { |
|
| 182 | + if (!empty($isCache)) { |
|
| 183 | 183 | return $this->getCache($cacheKey, ttl: $ttl); |
| 184 | 184 | } |
| 185 | 185 | |
@@ -224,7 +224,7 @@ discard block |
||
| 224 | 224 | * @param int|string $ttl |
| 225 | 225 | * @return bool |
| 226 | 226 | */ |
| 227 | - public function add(string $cacheKey, mixed $cacheData, string $namespace = '', int|string $ttl = 3600) |
|
| 227 | + public function add(string $cacheKey, mixed $cacheData, string $namespace = '', int | string $ttl = 3600) |
|
| 228 | 228 | { |
| 229 | 229 | if (!empty($this->getCache($cacheKey, $namespace))) { |
| 230 | 230 | return true; |
@@ -129,11 +129,11 @@ discard block |
||
| 129 | 129 | } |
| 130 | 130 | |
| 131 | 131 | /** |
| 132 | - * @param string $cacheKey |
|
| 133 | - * @param int $amount |
|
| 134 | - * @param string $namespace |
|
| 135 | - * @return bool |
|
| 136 | - */ |
|
| 132 | + * @param string $cacheKey |
|
| 133 | + * @param int $amount |
|
| 134 | + * @param string $namespace |
|
| 135 | + * @return bool |
|
| 136 | + */ |
|
| 137 | 137 | public function increment(string $cacheKey, int $amount = 1, string $namespace = '') |
| 138 | 138 | { |
| 139 | 139 | $cacheData = $this->getCache($cacheKey, $namespace); |
@@ -148,20 +148,20 @@ discard block |
||
| 148 | 148 | } |
| 149 | 149 | |
| 150 | 150 | /** |
| 151 | - * @param string $cacheKey |
|
| 152 | - * @param int $amount |
|
| 153 | - * @param string $namespace |
|
| 154 | - * @return bool |
|
| 155 | - */ |
|
| 151 | + * @param string $cacheKey |
|
| 152 | + * @param int $amount |
|
| 153 | + * @param string $namespace |
|
| 154 | + * @return bool |
|
| 155 | + */ |
|
| 156 | 156 | public function decrement(string $cacheKey, int $amount = 1, string $namespace = '') |
| 157 | 157 | { |
| 158 | - return $this->increment($cacheKey, ($amount * -1), $namespace); |
|
| 158 | + return $this->increment($cacheKey, ($amount * -1), $namespace); |
|
| 159 | 159 | } |
| 160 | 160 | /** |
| 161 | - * @param string $cacheKey |
|
| 162 | - * @param mixed $cacheData |
|
| 163 | - * @return void |
|
| 164 | - */ |
|
| 161 | + * @param string $cacheKey |
|
| 162 | + * @param mixed $cacheData |
|
| 163 | + * @return void |
|
| 164 | + */ |
|
| 165 | 165 | public function forever(string $cacheKey, mixed $cacheData) |
| 166 | 166 | { |
| 167 | 167 | $this->putCache($cacheKey, $cacheData, '', 31536000 * 1000); |
@@ -169,11 +169,11 @@ discard block |
||
| 169 | 169 | } |
| 170 | 170 | |
| 171 | 171 | /** |
| 172 | - * @param string $cacheKey |
|
| 173 | - * @param int|string $ttl |
|
| 174 | - * @param Closure $callback |
|
| 175 | - * @return mixed |
|
| 176 | - */ |
|
| 172 | + * @param string $cacheKey |
|
| 173 | + * @param int|string $ttl |
|
| 174 | + * @param Closure $callback |
|
| 175 | + * @return mixed |
|
| 176 | + */ |
|
| 177 | 177 | public function remember(string $cacheKey, int|string $ttl, Closure $callback) |
| 178 | 178 | { |
| 179 | 179 | $isCache = $this->getCache($cacheKey); |
@@ -191,20 +191,20 @@ discard block |
||
| 191 | 191 | } |
| 192 | 192 | |
| 193 | 193 | /** |
| 194 | - * @param string $cacheKey |
|
| 195 | - * @param Closure $callback |
|
| 196 | - * @return mixed |
|
| 197 | - */ |
|
| 194 | + * @param string $cacheKey |
|
| 195 | + * @param Closure $callback |
|
| 196 | + * @return mixed |
|
| 197 | + */ |
|
| 198 | 198 | public function rememberForever(string $cacheKey, Closure $callback) |
| 199 | 199 | { |
| 200 | 200 | return $this->remember($cacheKey, 31536000 * 1000, $callback); |
| 201 | 201 | } |
| 202 | 202 | |
| 203 | 203 | /** |
| 204 | - * @param string $cacheKey |
|
| 205 | - * @param string $namespace |
|
| 206 | - * @return mixed |
|
| 207 | - */ |
|
| 204 | + * @param string $cacheKey |
|
| 205 | + * @param string $namespace |
|
| 206 | + * @return mixed |
|
| 207 | + */ |
|
| 208 | 208 | public function getAndForget(string $cacheKey, string $namespace = '') |
| 209 | 209 | { |
| 210 | 210 | $cachedData = $this->getCache($cacheKey, $namespace); |
@@ -218,12 +218,12 @@ discard block |
||
| 218 | 218 | } |
| 219 | 219 | |
| 220 | 220 | /** |
| 221 | - * @param string $cacheKey |
|
| 222 | - * @param mixed $cacheData |
|
| 223 | - * @param string $namespace |
|
| 224 | - * @param int|string $ttl |
|
| 225 | - * @return bool |
|
| 226 | - */ |
|
| 221 | + * @param string $cacheKey |
|
| 222 | + * @param mixed $cacheData |
|
| 223 | + * @param string $namespace |
|
| 224 | + * @param int|string $ttl |
|
| 225 | + * @return bool |
|
| 226 | + */ |
|
| 227 | 227 | public function add(string $cacheKey, mixed $cacheData, string $namespace = '', int|string $ttl = 3600) |
| 228 | 228 | { |
| 229 | 229 | if (!empty($this->getCache($cacheKey, $namespace))) { |
@@ -258,13 +258,13 @@ discard block |
||
| 258 | 258 | { |
| 259 | 259 | $this->cache->flushCache(); |
| 260 | 260 | |
| 261 | - $value = $this->cache->remember('remember_test_key', 60, function () { |
|
| 261 | + $value = $this->cache->remember('remember_test_key', 60, function() { |
|
| 262 | 262 | return 'valor_teste'; |
| 263 | 263 | }); |
| 264 | 264 | |
| 265 | 265 | $this->assertEquals('valor_teste', $value); |
| 266 | 266 | |
| 267 | - $cachedValue = $this->cache->remember('remember_test_key', 60, function (){ |
|
| 267 | + $cachedValue = $this->cache->remember('remember_test_key', 60, function() { |
|
| 268 | 268 | return 'novo_valor'; |
| 269 | 269 | }); |
| 270 | 270 | |
@@ -276,12 +276,12 @@ discard block |
||
| 276 | 276 | { |
| 277 | 277 | $this->cache->flushCache(); |
| 278 | 278 | |
| 279 | - $value = $this->cache->rememberForever('remember_forever_key', function () { |
|
| 279 | + $value = $this->cache->rememberForever('remember_forever_key', function() { |
|
| 280 | 280 | return 'valor_eterno'; |
| 281 | 281 | }); |
| 282 | 282 | $this->assertEquals('valor_eterno', $value); |
| 283 | 283 | |
| 284 | - $cachedValue = $this->cache->rememberForever('remember_forever_key', function () { |
|
| 284 | + $cachedValue = $this->cache->rememberForever('remember_forever_key', function() { |
|
| 285 | 285 | return 'novo_valor'; |
| 286 | 286 | }); |
| 287 | 287 | |