@@ -47,7 +47,7 @@ discard block |
||
| 47 | 47 | * @param string|int $ttl |
| 48 | 48 | * @return mixed |
| 49 | 49 | */ |
| 50 | - public function getCache(string $cacheKey, string $namespace = '', string|int $ttl = 3600) |
|
| 50 | + public function getCache(string $cacheKey, string $namespace = '', string | int $ttl = 3600) |
|
| 51 | 51 | { |
| 52 | 52 | $cacheData = $this->retrieveCache($cacheKey, $namespace); |
| 53 | 53 | if ($cacheData) { |
@@ -66,9 +66,9 @@ discard block |
||
| 66 | 66 | * @param string|int $ttl |
| 67 | 67 | * @return bool |
| 68 | 68 | */ |
| 69 | - public function putCache(string $cacheKey, mixed $cacheData, string $namespace = '', string|int $ttl = 3600) |
|
| 69 | + public function putCache(string $cacheKey, mixed $cacheData, string $namespace = '', string | int $ttl = 3600) |
|
| 70 | 70 | { |
| 71 | - if($this->storeCache($cacheKey, $cacheData, $namespace, $ttl)){ |
|
| 71 | + if ($this->storeCache($cacheKey, $cacheData, $namespace, $ttl)) { |
|
| 72 | 72 | $this->logger->debug("{$this->getMessage()} from database driver."); |
| 73 | 73 | return true; |
| 74 | 74 | } |
@@ -151,7 +151,7 @@ discard block |
||
| 151 | 151 | public function clearCache(string $cacheKey, string $namespace = '') |
| 152 | 152 | { |
| 153 | 153 | $data = $this->cacheRepository->clear($cacheKey, $namespace); |
| 154 | - if($data) { |
|
| 154 | + if ($data) { |
|
| 155 | 155 | $this->setMessage("Cache deleted successfully!", true); |
| 156 | 156 | } else { |
| 157 | 157 | $this->setMessage("Cache does not exists!", false); |
@@ -165,7 +165,7 @@ discard block |
||
| 165 | 165 | */ |
| 166 | 166 | public function flushCache() |
| 167 | 167 | { |
| 168 | - if($this->cacheRepository->flush()){ |
|
| 168 | + if ($this->cacheRepository->flush()) { |
|
| 169 | 169 | $this->setMessage("Flush finished successfully", true); |
| 170 | 170 | } else { |
| 171 | 171 | $this->setMessage("Something went wrong. Please, try again.", false); |
@@ -193,10 +193,10 @@ discard block |
||
| 193 | 193 | * @param integer $ttl |
| 194 | 194 | * @return bool |
| 195 | 195 | */ |
| 196 | - private function storeCache(string $cacheKey, mixed $cacheData, string $namespace = '', string|int $ttl = 3600) |
|
| 196 | + private function storeCache(string $cacheKey, mixed $cacheData, string $namespace = '', string | int $ttl = 3600) |
|
| 197 | 197 | { |
| 198 | 198 | $data = $this->cacheRepository->store($cacheKey, $cacheData, $namespace, $ttl); |
| 199 | - if($data) { |
|
| 199 | + if ($data) { |
|
| 200 | 200 | $this->setMessage("Cache Stored Successfully", true); |
| 201 | 201 | return true; |
| 202 | 202 | } |
@@ -214,7 +214,7 @@ discard block |
||
| 214 | 214 | private function updateCache(string $cacheKey, mixed $cacheData, string $namespace = '') |
| 215 | 215 | { |
| 216 | 216 | $data = $this->cacheRepository->update($cacheKey, $cacheData, $namespace); |
| 217 | - if($data) { |
|
| 217 | + if ($data) { |
|
| 218 | 218 | $this->setMessage("Cache updated successfully.", true); |
| 219 | 219 | return true; |
| 220 | 220 | } |
@@ -228,7 +228,7 @@ discard block |
||
| 228 | 228 | * @param string $namespace |
| 229 | 229 | * @return bool |
| 230 | 230 | */ |
| 231 | - private function renew(string $cacheKey, string|int $ttl = 3600, string $namespace = '') |
|
| 231 | + private function renew(string $cacheKey, string | int $ttl = 3600, string $namespace = '') |
|
| 232 | 232 | { |
| 233 | 233 | $cacheData = $this->getCache($cacheKey, $namespace); |
| 234 | 234 | if ($cacheData) { |
@@ -250,7 +250,7 @@ discard block |
||
| 250 | 250 | */ |
| 251 | 251 | private function processBatchItems(array $batchItems, string $namespace) |
| 252 | 252 | { |
| 253 | - foreach($batchItems as $item) { |
|
| 253 | + foreach ($batchItems as $item) { |
|
| 254 | 254 | CacheDatabaseHelper::validateCacheItem($item); |
| 255 | 255 | $cacheKey = $item['cacheKey']; |
| 256 | 256 | $cacheData = $item['cacheData']; |
@@ -46,13 +46,13 @@ |
||
| 46 | 46 | private string $lastFlushTimeFile; |
| 47 | 47 | |
| 48 | 48 | /** |
| 49 | - * @var CacheLogger |
|
| 50 | - */ |
|
| 49 | + * @var CacheLogger |
|
| 50 | + */ |
|
| 51 | 51 | private $logger = null; |
| 52 | 52 | |
| 53 | 53 | /** |
| 54 | - * @var FileCacheManager |
|
| 55 | - */ |
|
| 54 | + * @var FileCacheManager |
|
| 55 | + */ |
|
| 56 | 56 | private FileCacheManager $fileManager; |
| 57 | 57 | |
| 58 | 58 | public function __construct(array $options = []) |
@@ -72,7 +72,7 @@ discard block |
||
| 72 | 72 | * @param string|int $ttl |
| 73 | 73 | * @return string |
| 74 | 74 | */ |
| 75 | - public function getCache(string $cacheKey, string $namespace = '', string|int $ttl = 3600) |
|
| 75 | + public function getCache(string $cacheKey, string $namespace = '', string | int $ttl = 3600) |
|
| 76 | 76 | { |
| 77 | 77 | |
| 78 | 78 | $ttl = CacheFileHelper::ttl($ttl, $this->defaultTTL); |
@@ -96,7 +96,7 @@ discard block |
||
| 96 | 96 | * @param string|int $ttl |
| 97 | 97 | * @return void |
| 98 | 98 | */ |
| 99 | - public function putCache(string $cacheKey, mixed $cacheData, string $namespace = '', string|int $ttl = 3600) |
|
| 99 | + public function putCache(string $cacheKey, mixed $cacheData, string $namespace = '', string | int $ttl = 3600) |
|
| 100 | 100 | { |
| 101 | 101 | $cacheFile = $this->buildCacheFilePath($cacheKey, $namespace); |
| 102 | 102 | $data = $this->fileManager->serialize($cacheData); |
@@ -171,7 +171,7 @@ discard block |
||
| 171 | 171 | * @param string $namespace |
| 172 | 172 | * @return void |
| 173 | 173 | */ |
| 174 | - public function renewCache(string $cacheKey, string|int $ttl, string $namespace = '') |
|
| 174 | + public function renewCache(string $cacheKey, string | int $ttl, string $namespace = '') |
|
| 175 | 175 | { |
| 176 | 176 | $cacheData = $this->getCache($cacheKey, $namespace); |
| 177 | 177 | if ($cacheData) { |
@@ -278,12 +278,12 @@ discard block |
||
| 278 | 278 | { |
| 279 | 279 | $flushAfterSeconds = CacheFileHelper::convertExpirationToSeconds($flushAfter); |
| 280 | 280 | |
| 281 | - if(!$this->fileManager->fileExists($this->lastFlushTimeFile)) { |
|
| 281 | + if (!$this->fileManager->fileExists($this->lastFlushTimeFile)) { |
|
| 282 | 282 | $this->fileManager->writeFile($this->lastFlushTimeFile, time()); |
| 283 | 283 | return; |
| 284 | 284 | } |
| 285 | 285 | |
| 286 | - $lastFlushTime = (int) $this->fileManager->readFile($this->lastFlushTimeFile); |
|
| 286 | + $lastFlushTime = (int)$this->fileManager->readFile($this->lastFlushTimeFile); |
|
| 287 | 287 | |
| 288 | 288 | if ((time() - $lastFlushTime) >= $flushAfterSeconds) { |
| 289 | 289 | $this->flushCache(); |
@@ -15,9 +15,9 @@ |
||
| 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()]; |
@@ -18,9 +18,9 @@ discard block |
||
| 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 |
||
| 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 |
||
| 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; |
@@ -13,8 +13,8 @@ |
||
| 13 | 13 | class MigrationManager |
| 14 | 14 | { |
| 15 | 15 | /** |
| 16 | - * @return void |
|
| 17 | - */ |
|
| 16 | + * @return void |
|
| 17 | + */ |
|
| 18 | 18 | public static function migrate(PDO $connection) |
| 19 | 19 | { |
| 20 | 20 | $driver = $connection->getAttribute(PDO::ATTR_DRIVER_NAME); |
@@ -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 | |
@@ -8,34 +8,34 @@ |
||
| 8 | 8 | { |
| 9 | 9 | |
| 10 | 10 | |
| 11 | - /** @param string $before */ |
|
| 12 | - private static string $before = "<Redis Cache Store Exception>"; |
|
| 11 | + /** @param string $before */ |
|
| 12 | + private static string $before = "<Redis Cache Store Exception>"; |
|
| 13 | 13 | |
| 14 | 14 | |
| 15 | - /** |
|
| 16 | - * @return void |
|
| 17 | - */ |
|
| 18 | - public static function create(string $message = "", int $code = 0, ?Exception $previous = null, array $details = []) |
|
| 19 | - { |
|
| 15 | + /** |
|
| 16 | + * @return void |
|
| 17 | + */ |
|
| 18 | + public static function create(string $message = "", int $code = 0, ?Exception $previous = null, array $details = []) |
|
| 19 | + { |
|
| 20 | 20 | return new self(self::getBefore() . ": " .$message, $code, $previous, $details); |
| 21 | - } |
|
| 21 | + } |
|
| 22 | 22 | |
| 23 | 23 | |
| 24 | - /** |
|
| 25 | - * @return string |
|
| 26 | - */ |
|
| 27 | - public static function getBefore() |
|
| 28 | - { |
|
| 24 | + /** |
|
| 25 | + * @return string |
|
| 26 | + */ |
|
| 27 | + public static function getBefore() |
|
| 28 | + { |
|
| 29 | 29 | return self::$before; |
| 30 | - } |
|
| 30 | + } |
|
| 31 | 31 | |
| 32 | - /** |
|
| 33 | - * @return void |
|
| 34 | - */ |
|
| 35 | - public static function setBefore(string $text) |
|
| 36 | - { |
|
| 32 | + /** |
|
| 33 | + * @return void |
|
| 34 | + */ |
|
| 35 | + public static function setBefore(string $text) |
|
| 36 | + { |
|
| 37 | 37 | self::$before = $text; |
| 38 | - } |
|
| 38 | + } |
|
| 39 | 39 | |
| 40 | 40 | } |
| 41 | 41 | |
@@ -7,32 +7,32 @@ |
||
| 7 | 7 | class CacheDatabaseException extends BaseException |
| 8 | 8 | { |
| 9 | 9 | |
| 10 | - /** @param string $before */ |
|
| 11 | - private static string $before = "<Database 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 = "<Database 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 | } |
@@ -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 | |
@@ -7,31 +7,31 @@ |
||
| 7 | 7 | class ConnectionException extends BaseException |
| 8 | 8 | { |
| 9 | 9 | |
| 10 | - /** @param string $before */ |
|
| 11 | - private static string $before = "<Connection 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 = "<Connection 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 | - /** |
|
| 22 | - * @return string |
|
| 23 | - */ |
|
| 24 | - public static function getBefore() |
|
| 25 | - { |
|
| 21 | + /** |
|
| 22 | + * @return string |
|
| 23 | + */ |
|
| 24 | + public static function getBefore() |
|
| 25 | + { |
|
| 26 | 26 | return self::$before; |
| 27 | - } |
|
| 27 | + } |
|
| 28 | 28 | |
| 29 | - /** |
|
| 30 | - * @return void |
|
| 31 | - */ |
|
| 32 | - public static function setBefore(string $text) |
|
| 33 | - { |
|
| 29 | + /** |
|
| 30 | + * @return void |
|
| 31 | + */ |
|
| 32 | + public static function setBefore(string $text) |
|
| 33 | + { |
|
| 34 | 34 | self::$before = $text; |
| 35 | - } |
|
| 35 | + } |
|
| 36 | 36 | |
| 37 | 37 | } |
@@ -15,7 +15,7 @@ |
||
| 15 | 15 | */ |
| 16 | 16 | public static function create(string $message = "", int $code = 0, ?Exception $previous = null, array $details = []) |
| 17 | 17 | { |
| 18 | - return new self(self::getBefore() . ": " .$message, $code, $previous, $details); |
|
| 18 | + return new self(self::getBefore() . ": " . $message, $code, $previous, $details); |
|
| 19 | 19 | } |
| 20 | 20 | |
| 21 | 21 | /** |
@@ -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 | |