@@ -43,18 +43,18 @@ |
||
43 | 43 | |
44 | 44 | |
45 | 45 | /** |
46 | - * @var CacheLogger |
|
47 | - */ |
|
46 | + * @var CacheLogger |
|
47 | + */ |
|
48 | 48 | private $logger = null; |
49 | 49 | |
50 | 50 | /** |
51 | - * @var FileCacheManager |
|
52 | - */ |
|
51 | + * @var FileCacheManager |
|
52 | + */ |
|
53 | 53 | private FileCacheManager $fileManager; |
54 | 54 | |
55 | 55 | /** |
56 | - * @var FileCacheFlusher |
|
57 | - */ |
|
56 | + * @var FileCacheFlusher |
|
57 | + */ |
|
58 | 58 | private FileCacheFlusher $flusher; |
59 | 59 | |
60 | 60 |
@@ -53,18 +53,18 @@ discard block |
||
53 | 53 | } |
54 | 54 | |
55 | 55 | /** |
56 | - * @param string $filename |
|
57 | - * @return bool |
|
58 | - */ |
|
56 | + * @param string $filename |
|
57 | + * @return bool |
|
58 | + */ |
|
59 | 59 | public function fileExists(string $filename): bool |
60 | 60 | { |
61 | 61 | return file_exists($filename); |
62 | 62 | } |
63 | 63 | |
64 | 64 | /** |
65 | - * @param string $filename |
|
66 | - * @return void |
|
67 | - */ |
|
65 | + * @param string $filename |
|
66 | + * @return void |
|
67 | + */ |
|
68 | 68 | public function removeFile(string $filename): void |
69 | 69 | { |
70 | 70 | if (file_exists($filename)) { |
@@ -73,9 +73,9 @@ discard block |
||
73 | 73 | } |
74 | 74 | |
75 | 75 | /** |
76 | - * @param string $dir |
|
77 | - * @return void |
|
78 | - */ |
|
76 | + * @param string $dir |
|
77 | + * @return void |
|
78 | + */ |
|
79 | 79 | public function clearDirectory(string $dir): void |
80 | 80 | { |
81 | 81 | $iterator = new RecursiveIteratorIterator( |
@@ -14,42 +14,42 @@ |
||
14 | 14 | class RedisCacheManager |
15 | 15 | { |
16 | 16 | |
17 | - /** @var Predis\Client */ |
|
18 | - private static $redis; |
|
19 | - |
|
20 | - /** @param string $namespace */ |
|
21 | - private static $namespace; |
|
22 | - |
|
23 | - /** |
|
24 | - * Connects to the Redis server using the configuration defined in REDIS_CONNECTION_CONFIG. |
|
25 | - * |
|
26 | - * @return Client |
|
27 | - */ |
|
28 | - public static function connect() |
|
29 | - { |
|
17 | + /** @var Predis\Client */ |
|
18 | + private static $redis; |
|
19 | + |
|
20 | + /** @param string $namespace */ |
|
21 | + private static $namespace; |
|
22 | + |
|
23 | + /** |
|
24 | + * Connects to the Redis server using the configuration defined in REDIS_CONNECTION_CONFIG. |
|
25 | + * |
|
26 | + * @return Client |
|
27 | + */ |
|
28 | + public static function connect() |
|
29 | + { |
|
30 | 30 | Autoloader::register(); |
31 | 31 | self::$redis = new Client([ |
32 | - 'scheme' => 'tcp', |
|
33 | - 'host' => REDIS_CONNECTION_CONFIG['REDIS_HOST'], |
|
34 | - 'port' => REDIS_CONNECTION_CONFIG['REDIS_PORT'], |
|
35 | - 'password' => REDIS_CONNECTION_CONFIG['REDIS_PASSWORD'], |
|
36 | - 'database' => 0 |
|
32 | + 'scheme' => 'tcp', |
|
33 | + 'host' => REDIS_CONNECTION_CONFIG['REDIS_HOST'], |
|
34 | + 'port' => REDIS_CONNECTION_CONFIG['REDIS_PORT'], |
|
35 | + 'password' => REDIS_CONNECTION_CONFIG['REDIS_PASSWORD'], |
|
36 | + 'database' => 0 |
|
37 | 37 | ]); |
38 | 38 | self::auth(); |
39 | 39 | self::$namespace = REDIS_CONNECTION_CONFIG['REDIS_NAMESPACE'] ?? 'Cache'; |
40 | 40 | return self::$redis; |
41 | - } |
|
42 | - |
|
43 | - /** |
|
44 | - * Authenticates the Redis connection if a password is provided in the configuration. |
|
45 | - * |
|
46 | - * @return void |
|
47 | - */ |
|
48 | - private static function auth(): void |
|
49 | - { |
|
41 | + } |
|
42 | + |
|
43 | + /** |
|
44 | + * Authenticates the Redis connection if a password is provided in the configuration. |
|
45 | + * |
|
46 | + * @return void |
|
47 | + */ |
|
48 | + private static function auth(): void |
|
49 | + { |
|
50 | 50 | if(is_string(REDIS_CONNECTION_CONFIG['REDIS_PASSWORD']) && REDIS_CONNECTION_CONFIG['REDIS_PASSWORD'] !== '') { |
51 | - self::$redis->auth(REDIS_CONNECTION_CONFIG['REDIS_PASSWORD']); |
|
51 | + self::$redis->auth(REDIS_CONNECTION_CONFIG['REDIS_PASSWORD']); |
|
52 | + } |
|
52 | 53 | } |
53 | - } |
|
54 | 54 | |
55 | 55 | } |
@@ -13,18 +13,18 @@ discard block |
||
13 | 13 | class FileCacheFlusher |
14 | 14 | { |
15 | 15 | /** |
16 | - * @var FileCacheManager |
|
17 | - */ |
|
16 | + * @var FileCacheManager |
|
17 | + */ |
|
18 | 18 | private FileCacheManager $fileManager; |
19 | 19 | |
20 | 20 | /** |
21 | - * @var string $cacheDir |
|
22 | - */ |
|
21 | + * @var string $cacheDir |
|
22 | + */ |
|
23 | 23 | private string $cacheDir; |
24 | 24 | |
25 | 25 | /** |
26 | - * @var string $lastFlushTimeFile |
|
27 | - */ |
|
26 | + * @var string $lastFlushTimeFile |
|
27 | + */ |
|
28 | 28 | private string $lastFlushTimeFile; |
29 | 29 | |
30 | 30 | /** |
@@ -41,10 +41,10 @@ discard block |
||
41 | 41 | } |
42 | 42 | |
43 | 43 | /** |
44 | - * Flushes all cache items and updates the last flush timestamp. |
|
45 | - * |
|
46 | - * @return void |
|
47 | - */ |
|
44 | + * Flushes all cache items and updates the last flush timestamp. |
|
45 | + * |
|
46 | + * @return void |
|
47 | + */ |
|
48 | 48 | public function flushCache(): void |
49 | 49 | { |
50 | 50 | $this->fileManager->clearDirectory($this->cacheDir); |
@@ -52,11 +52,11 @@ discard block |
||
52 | 52 | } |
53 | 53 | |
54 | 54 | /** |
55 | - * Handles the auto-flush functionality based on options. |
|
56 | - * |
|
57 | - * @param array $options |
|
58 | - * @return void |
|
59 | - */ |
|
55 | + * Handles the auto-flush functionality based on options. |
|
56 | + * |
|
57 | + * @param array $options |
|
58 | + * @return void |
|
59 | + */ |
|
60 | 60 | public function handleAutoFlush(array $options): void |
61 | 61 | { |
62 | 62 | if (isset($options['flushAfter'])) { |
@@ -16,15 +16,15 @@ |
||
16 | 16 | class CacheRetriever |
17 | 17 | { |
18 | 18 | /** |
19 | - * @var Cacheer |
|
20 | - */ |
|
19 | + * @var Cacheer |
|
20 | + */ |
|
21 | 21 | private Cacheer $cacheer; |
22 | 22 | |
23 | 23 | /** |
24 | - * CacheRetriever constructor. |
|
25 | - * |
|
26 | - * @param Cacheer $cacheer |
|
27 | - */ |
|
24 | + * CacheRetriever constructor. |
|
25 | + * |
|
26 | + * @param Cacheer $cacheer |
|
27 | + */ |
|
28 | 28 | public function __construct(Cacheer $cacheer) |
29 | 29 | { |
30 | 30 | $this->cacheer = $cacheer; |
@@ -13,20 +13,20 @@ discard block |
||
13 | 13 | private mixed $data; |
14 | 14 | |
15 | 15 | /** |
16 | - * CacheDataFormatter constructor. |
|
17 | - * |
|
18 | - * @param mixed $data |
|
19 | - */ |
|
16 | + * CacheDataFormatter constructor. |
|
17 | + * |
|
18 | + * @param mixed $data |
|
19 | + */ |
|
20 | 20 | public function __construct(mixed $data) |
21 | 21 | { |
22 | 22 | $this->data = $data; |
23 | 23 | } |
24 | 24 | |
25 | 25 | /** |
26 | - * Converts the data to JSON format. |
|
27 | - * |
|
28 | - * @return string|false |
|
29 | - */ |
|
26 | + * Converts the data to JSON format. |
|
27 | + * |
|
28 | + * @return string|false |
|
29 | + */ |
|
30 | 30 | public function toJson(): bool|string |
31 | 31 | { |
32 | 32 | return json_encode( |
@@ -38,30 +38,30 @@ discard block |
||
38 | 38 | } |
39 | 39 | |
40 | 40 | /** |
41 | - * Converts the data to an array. |
|
42 | - * |
|
43 | - * @return array |
|
44 | - */ |
|
41 | + * Converts the data to an array. |
|
42 | + * |
|
43 | + * @return array |
|
44 | + */ |
|
45 | 45 | public function toArray(): array |
46 | 46 | { |
47 | 47 | return (array)$this->data; |
48 | 48 | } |
49 | 49 | |
50 | 50 | /** |
51 | - * Converts the data to a string. |
|
52 | - * |
|
53 | - * @return string |
|
54 | - */ |
|
51 | + * Converts the data to a string. |
|
52 | + * |
|
53 | + * @return string |
|
54 | + */ |
|
55 | 55 | public function toString(): string |
56 | 56 | { |
57 | 57 | return (string)$this->data; |
58 | 58 | } |
59 | 59 | |
60 | 60 | /** |
61 | - * Converts the data to an object. |
|
62 | - * |
|
63 | - * @return object |
|
64 | - */ |
|
61 | + * Converts the data to an object. |
|
62 | + * |
|
63 | + * @return object |
|
64 | + */ |
|
65 | 65 | public function toObject(): object |
66 | 66 | { |
67 | 67 | return (object)$this->data; |
@@ -23,40 +23,40 @@ discard block |
||
23 | 23 | } |
24 | 24 | |
25 | 25 | /** |
26 | - * Logs a info message. |
|
27 | - * |
|
28 | - * @return void |
|
29 | - */ |
|
26 | + * Logs a info message. |
|
27 | + * |
|
28 | + * @return void |
|
29 | + */ |
|
30 | 30 | public function info($message): void |
31 | 31 | { |
32 | 32 | $this->log('INFO', $message); |
33 | 33 | } |
34 | 34 | |
35 | 35 | /** |
36 | - * Logs a warning message. |
|
37 | - * |
|
38 | - * @return void |
|
39 | - */ |
|
36 | + * Logs a warning message. |
|
37 | + * |
|
38 | + * @return void |
|
39 | + */ |
|
40 | 40 | public function warning($message): void |
41 | 41 | { |
42 | 42 | $this->log('WARNING', $message); |
43 | 43 | } |
44 | 44 | |
45 | 45 | /** |
46 | - * Logs an error message. |
|
47 | - * |
|
48 | - * @return void |
|
49 | - */ |
|
46 | + * Logs an error message. |
|
47 | + * |
|
48 | + * @return void |
|
49 | + */ |
|
50 | 50 | public function error($message): void |
51 | 51 | { |
52 | 52 | $this->log('ERROR', $message); |
53 | 53 | } |
54 | 54 | |
55 | 55 | /** |
56 | - * Logs a debug message. |
|
57 | - * |
|
58 | - * @return void |
|
59 | - */ |
|
56 | + * Logs a debug message. |
|
57 | + * |
|
58 | + * @return void |
|
59 | + */ |
|
60 | 60 | public function debug($message): void |
61 | 61 | { |
62 | 62 | $this->log('DEBUG', $message); |
@@ -74,10 +74,10 @@ discard block |
||
74 | 74 | } |
75 | 75 | |
76 | 76 | /** |
77 | - * Rotates the log file if it exceeds the maximum size. |
|
78 | - * |
|
79 | - * @return void |
|
80 | - */ |
|
77 | + * Rotates the log file if it exceeds the maximum size. |
|
78 | + * |
|
79 | + * @return void |
|
80 | + */ |
|
81 | 81 | private function rotateLog(): void |
82 | 82 | { |
83 | 83 | if (file_exists($this->logFile) && filesize($this->logFile) >= $this->maxFileSize) { |
@@ -87,12 +87,12 @@ discard block |
||
87 | 87 | } |
88 | 88 | |
89 | 89 | /** |
90 | - * Logs a message to the log file. |
|
91 | - * |
|
92 | - * @param mixed $level |
|
93 | - * @param string $message |
|
94 | - * @return void |
|
95 | - */ |
|
90 | + * Logs a message to the log file. |
|
91 | + * |
|
92 | + * @param mixed $level |
|
93 | + * @param string $message |
|
94 | + * @return void |
|
95 | + */ |
|
96 | 96 | private function log(mixed $level, string $message): void |
97 | 97 | { |
98 | 98 | if (!$this->shouldLog($level)) { |
@@ -14,18 +14,18 @@ discard block |
||
14 | 14 | class Connect |
15 | 15 | { |
16 | 16 | /** |
17 | - * The default connection type. |
|
18 | - * Currently, it supports 'mysql', 'sqlite', and 'pgsql'. |
|
19 | - * |
|
20 | - * @var string |
|
21 | - */ |
|
17 | + * The default connection type. |
|
18 | + * Currently, it supports 'mysql', 'sqlite', and 'pgsql'. |
|
19 | + * |
|
20 | + * @var string |
|
21 | + */ |
|
22 | 22 | public static string $connection = 'sqlite'; |
23 | 23 | |
24 | 24 | /** |
25 | - * Holds the last error encountered during connection attempts. |
|
26 | - * |
|
27 | - * @var PDOException|null |
|
28 | - */ |
|
25 | + * Holds the last error encountered during connection attempts. |
|
26 | + * |
|
27 | + * @var PDOException|null |
|
28 | + */ |
|
29 | 29 | private static ?PDOException $error = null; |
30 | 30 | |
31 | 31 | |
@@ -62,20 +62,20 @@ discard block |
||
62 | 62 | } |
63 | 63 | |
64 | 64 | /** |
65 | - * Gets the current connection type. |
|
66 | - * |
|
67 | - * @return string |
|
68 | - */ |
|
65 | + * Gets the current connection type. |
|
66 | + * |
|
67 | + * @return string |
|
68 | + */ |
|
69 | 69 | public static function getConnection(): string |
70 | 70 | { |
71 | 71 | return self::$connection; |
72 | 72 | } |
73 | 73 | |
74 | 74 | /** |
75 | - * Returns the last error encountered during connection attempts.\ |
|
76 | - * |
|
77 | - * @return PDOException|null |
|
78 | - */ |
|
75 | + * Returns the last error encountered during connection attempts.\ |
|
76 | + * |
|
77 | + * @return PDOException|null |
|
78 | + */ |
|
79 | 79 | public static function getError(): ?PDOException |
80 | 80 | { |
81 | 81 | return self::$error; |
@@ -86,13 +86,13 @@ discard block |
||
86 | 86 | * This class is designed to be used statically, so it cannot be instantiated. |
87 | 87 | * |
88 | 88 | * @return void |
89 | - */ |
|
89 | + */ |
|
90 | 90 | private function __construct() {} |
91 | 91 | |
92 | 92 | /** |
93 | - * Prevents cloning of the Connect instance. |
|
94 | - * |
|
95 | - * @return void |
|
96 | - */ |
|
93 | + * Prevents cloning of the Connect instance. |
|
94 | + * |
|
95 | + * @return void |
|
96 | + */ |
|
97 | 97 | private function __clone() {} |
98 | 98 | } |
@@ -82,15 +82,15 @@ |
||
82 | 82 | return $ttl; |
83 | 83 | } |
84 | 84 | |
85 | - /** |
|
86 | - * Generates an array identifier for cache data. |
|
87 | - * |
|
88 | - * @param mixed $currentCacheData |
|
89 | - * @param mixed $cacheData |
|
90 | - * @return array |
|
91 | - */ |
|
92 | - public static function arrayIdentifier(mixed $currentCacheData, mixed $cacheData): array |
|
93 | - { |
|
85 | + /** |
|
86 | + * Generates an array identifier for cache data. |
|
87 | + * |
|
88 | + * @param mixed $currentCacheData |
|
89 | + * @param mixed $cacheData |
|
90 | + * @return array |
|
91 | + */ |
|
92 | + public static function arrayIdentifier(mixed $currentCacheData, mixed $cacheData): array |
|
93 | + { |
|
94 | 94 | return CacheerHelper::arrayIdentifier($currentCacheData, $cacheData); |
95 | - } |
|
95 | + } |
|
96 | 96 | } |