@@ -60,11 +60,11 @@ discard block |
||
60 | 60 | } |
61 | 61 | |
62 | 62 | /** |
63 | - * Retrieves cache data from the database. |
|
64 | - * |
|
65 | - * @param string $cacheKey |
|
66 | - * @param string $namespace |
|
67 | - * @return mixed |
|
63 | + * Retrieves cache data from the database. |
|
64 | + * |
|
65 | + * @param string $cacheKey |
|
66 | + * @param string $namespace |
|
67 | + * @return mixed |
|
68 | 68 | */ |
69 | 69 | public function retrieve(string $cacheKey, string $namespace = ''): mixed |
70 | 70 | { |
@@ -109,10 +109,10 @@ discard block |
||
109 | 109 | } |
110 | 110 | |
111 | 111 | /** |
112 | - * Get Update query based on the database driver. |
|
113 | - * |
|
114 | - * @return string |
|
115 | - */ |
|
112 | + * Get Update query based on the database driver. |
|
113 | + * |
|
114 | + * @return string |
|
115 | + */ |
|
116 | 116 | private function getUpdateQueryWithDriver(): string |
117 | 117 | { |
118 | 118 | $driver = $this->connection->getAttribute(PDO::ATTR_DRIVER_NAME); |
@@ -123,10 +123,10 @@ discard block |
||
123 | 123 | } |
124 | 124 | |
125 | 125 | /** |
126 | - * Get Delete query based on the database driver. |
|
127 | - * |
|
128 | - * @return string |
|
129 | - */ |
|
126 | + * Get Delete query based on the database driver. |
|
127 | + * |
|
128 | + * @return string |
|
129 | + */ |
|
130 | 130 | private function getDeleteQueryWithDriver(): string |
131 | 131 | { |
132 | 132 | $driver = $this->connection->getAttribute(PDO::ATTR_DRIVER_NAME); |
@@ -137,13 +137,13 @@ discard block |
||
137 | 137 | } |
138 | 138 | |
139 | 139 | /** |
140 | - * Updates an existing cache item in the database. |
|
141 | - * |
|
142 | - * @param string $cacheKey |
|
143 | - * @param mixed $cacheData |
|
144 | - * @param string $namespace |
|
145 | - * @return bool |
|
146 | - */ |
|
140 | + * Updates an existing cache item in the database. |
|
141 | + * |
|
142 | + * @param string $cacheKey |
|
143 | + * @param mixed $cacheData |
|
144 | + * @param string $namespace |
|
145 | + * @return bool |
|
146 | + */ |
|
147 | 147 | public function update(string $cacheKey, mixed $cacheData, string $namespace = ''): bool |
148 | 148 | { |
149 | 149 | $query = $this->getUpdateQueryWithDriver(); |
@@ -157,12 +157,12 @@ discard block |
||
157 | 157 | } |
158 | 158 | |
159 | 159 | /** |
160 | - * Clears a specific cache item from the database. |
|
161 | - * |
|
162 | - * @param string $cacheKey |
|
163 | - * @param string $namespace |
|
164 | - * @return bool |
|
165 | - */ |
|
160 | + * Clears a specific cache item from the database. |
|
161 | + * |
|
162 | + * @param string $cacheKey |
|
163 | + * @param string $namespace |
|
164 | + * @return bool |
|
165 | + */ |
|
166 | 166 | public function clear(string $cacheKey, string $namespace = ''): bool |
167 | 167 | { |
168 | 168 | $query = $this->getDeleteQueryWithDriver(); |
@@ -175,10 +175,10 @@ discard block |
||
175 | 175 | } |
176 | 176 | |
177 | 177 | /** |
178 | - * Gets the query to renew the expiration time of a cache item based on the database driver. |
|
179 | - * |
|
180 | - * @return string |
|
181 | - */ |
|
178 | + * Gets the query to renew the expiration time of a cache item based on the database driver. |
|
179 | + * |
|
180 | + * @return string |
|
181 | + */ |
|
182 | 182 | private function getRenewExpirationQueryWithDriver(): string |
183 | 183 | { |
184 | 184 | $driver = $this->connection->getAttribute(PDO::ATTR_DRIVER_NAME); |
@@ -193,13 +193,13 @@ discard block |
||
193 | 193 | } |
194 | 194 | |
195 | 195 | /** |
196 | - * Checks if a cache item is valid based on its key, namespace, and current time. |
|
197 | - * |
|
198 | - * @param string $cacheKey |
|
199 | - * @param string $namespace |
|
200 | - * @param string $currentTime |
|
201 | - * @return bool |
|
202 | - */ |
|
196 | + * Checks if a cache item is valid based on its key, namespace, and current time. |
|
197 | + * |
|
198 | + * @param string $cacheKey |
|
199 | + * @param string $namespace |
|
200 | + * @param string $currentTime |
|
201 | + * @return bool |
|
202 | + */ |
|
203 | 203 | private function hasValidCache(string $cacheKey, string $namespace, string $currentTime): bool |
204 | 204 | { |
205 | 205 | $stmt = $this->connection->prepare( |
@@ -215,13 +215,13 @@ discard block |
||
215 | 215 | } |
216 | 216 | |
217 | 217 | /** |
218 | - * Renews the expiration time of a cache item. |
|
219 | - * |
|
220 | - * @param string $cacheKey |
|
221 | - * @param string|int $ttl |
|
222 | - * @param string $namespace |
|
223 | - * @return bool |
|
224 | - */ |
|
218 | + * Renews the expiration time of a cache item. |
|
219 | + * |
|
220 | + * @param string $cacheKey |
|
221 | + * @param string|int $ttl |
|
222 | + * @param string $namespace |
|
223 | + * @return bool |
|
224 | + */ |
|
225 | 225 | public function renew(string $cacheKey, string|int $ttl, string $namespace = ''): bool |
226 | 226 | { |
227 | 227 | $currentTime = date('Y-m-d H:i:s'); |
@@ -241,10 +241,10 @@ discard block |
||
241 | 241 | } |
242 | 242 | |
243 | 243 | /** |
244 | - * Flushes all cache items from the database. |
|
245 | - * |
|
246 | - * @return bool |
|
247 | - */ |
|
244 | + * Flushes all cache items from the database. |
|
245 | + * |
|
246 | + * @return bool |
|
247 | + */ |
|
248 | 248 | public function flush(): bool |
249 | 249 | { |
250 | 250 | return $this->connection->exec("DELETE FROM cacheer_table") !== false; |
@@ -263,11 +263,11 @@ discard block |
||
263 | 263 | } |
264 | 264 | |
265 | 265 | /** |
266 | - * Gets the current date and time based on the database driver. |
|
267 | - * |
|
268 | - * @param string $driver |
|
269 | - * @return string |
|
270 | - */ |
|
266 | + * Gets the current date and time based on the database driver. |
|
267 | + * |
|
268 | + * @param string $driver |
|
269 | + * @return string |
|
270 | + */ |
|
271 | 271 | private function getCurrentDateTime(string $driver): string |
272 | 272 | { |
273 | 273 | return ($driver === 'sqlite') ? "DATETIME('now', 'localtime')" : "NOW()"; |
@@ -37,7 +37,7 @@ discard block |
||
37 | 37 | * @param string|int $ttl |
38 | 38 | * @return bool |
39 | 39 | */ |
40 | - public function store(string $cacheKey, mixed $cacheData, string $namespace, string|int $ttl = 3600): bool |
|
40 | + public function store(string $cacheKey, mixed $cacheData, string $namespace, string | int $ttl = 3600): bool |
|
41 | 41 | { |
42 | 42 | if (!empty($this->retrieve($cacheKey, $namespace))) { |
43 | 43 | return $this->update($cacheKey, $cacheData, $namespace); |
@@ -222,7 +222,7 @@ discard block |
||
222 | 222 | * @param string $namespace |
223 | 223 | * @return bool |
224 | 224 | */ |
225 | - public function renew(string $cacheKey, string|int $ttl, string $namespace = ''): bool |
|
225 | + public function renew(string $cacheKey, string | int $ttl, string $namespace = ''): bool |
|
226 | 226 | { |
227 | 227 | $currentTime = date('Y-m-d H:i:s'); |
228 | 228 | if (!$this->hasValidCache($cacheKey, $namespace, $currentTime)) { |
@@ -231,7 +231,7 @@ discard block |
||
231 | 231 | |
232 | 232 | $query = $this->getRenewExpirationQueryWithDriver(); |
233 | 233 | $stmt = $this->connection->prepare($query); |
234 | - $stmt->bindValue(':ttl', (int) $ttl, PDO::PARAM_INT); |
|
234 | + $stmt->bindValue(':ttl', (int)$ttl, PDO::PARAM_INT); |
|
235 | 235 | $stmt->bindValue(':cacheKey', $cacheKey); |
236 | 236 | $stmt->bindValue(':namespace', $namespace); |
237 | 237 | $stmt->bindValue(':currentTime', $currentTime); |
@@ -12,13 +12,13 @@ |
||
12 | 12 | class OptionBuilder |
13 | 13 | { |
14 | 14 | |
15 | - /** |
|
16 | - * Creates a FileOptionBuilder instance for file-based cache options. |
|
17 | - * |
|
18 | - * @return FileOptionBuilder |
|
19 | - */ |
|
20 | - public static function forFile(): FileOptionBuilder |
|
21 | - { |
|
15 | + /** |
|
16 | + * Creates a FileOptionBuilder instance for file-based cache options. |
|
17 | + * |
|
18 | + * @return FileOptionBuilder |
|
19 | + */ |
|
20 | + public static function forFile(): FileOptionBuilder |
|
21 | + { |
|
22 | 22 | return new FileOptionBuilder(); |
23 | - } |
|
23 | + } |
|
24 | 24 | } |
@@ -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; |
@@ -39,12 +39,12 @@ discard block |
||
39 | 39 | * @return mixed |
40 | 40 | * @throws CacheFileException |
41 | 41 | */ |
42 | - public function getCache(string $cacheKey, string $namespace = '', int|string $ttl = 3600): mixed |
|
42 | + public function getCache(string $cacheKey, string $namespace = '', int | string $ttl = 3600): mixed |
|
43 | 43 | { |
44 | 44 | $cacheData = $this->cacheer->cacheStore->getCache($cacheKey, $namespace, $ttl); |
45 | 45 | $this->cacheer->syncState(); |
46 | 46 | |
47 | - if ($this->cacheer->isSuccess() && ($this->cacheer->isCompressionEnabled() || $this->cacheer->getEncryptionKey() !== null)) { |
|
47 | + if ($this->cacheer->isSuccess() && ($this->cacheer->isCompressionEnabled() || $this->cacheer->getEncryptionKey() !== null)) { |
|
48 | 48 | $cacheData = CacheerHelper::recoverFromStorage($cacheData, $this->cacheer->isCompressionEnabled(), $this->cacheer->getEncryptionKey()); |
49 | 49 | } |
50 | 50 | |
@@ -60,7 +60,7 @@ discard block |
||
60 | 60 | * @return array|CacheDataFormatter |
61 | 61 | * @throws CacheFileException |
62 | 62 | */ |
63 | - public function getMany(array $cacheKeys, string $namespace = '', int|string $ttl = 3600): array|CacheDataFormatter |
|
63 | + public function getMany(array $cacheKeys, string $namespace = '', int | string $ttl = 3600): array | CacheDataFormatter |
|
64 | 64 | { |
65 | 65 | $cachedData = $this->cacheer->cacheStore->getMany($cacheKeys, $namespace, $ttl); |
66 | 66 | return $this->getCachedDatum($cachedData); |
@@ -109,7 +109,7 @@ discard block |
||
109 | 109 | * @return mixed |
110 | 110 | * @throws CacheFileException |
111 | 111 | */ |
112 | - public function remember(string $cacheKey, int|string $ttl, Closure $callback): mixed |
|
112 | + public function remember(string $cacheKey, int | string $ttl, Closure $callback): mixed |
|
113 | 113 | { |
114 | 114 | $cachedData = $this->getCache($cacheKey, ttl: $ttl); |
115 | 115 |
@@ -13,24 +13,24 @@ discard block |
||
13 | 13 | class TimeBuilder |
14 | 14 | { |
15 | 15 | |
16 | - /** @param Closure $callback */ |
|
17 | - private Closure $callback; |
|
16 | + /** @param Closure $callback */ |
|
17 | + private Closure $callback; |
|
18 | 18 | |
19 | - /** @var ?FileOptionBuilder */ |
|
20 | - private ?FileOptionBuilder $builder = null; |
|
19 | + /** @var ?FileOptionBuilder */ |
|
20 | + private ?FileOptionBuilder $builder = null; |
|
21 | 21 | |
22 | - /** |
|
23 | - * TimeBuilder constructor. |
|
24 | - * @param Closure $callback |
|
25 | - * @param FileOptionBuilder $builder |
|
26 | - * |
|
27 | - * @return void |
|
28 | - */ |
|
29 | - public function __construct(Closure $callback, FileOptionBuilder $builder) |
|
30 | - { |
|
22 | + /** |
|
23 | + * TimeBuilder constructor. |
|
24 | + * @param Closure $callback |
|
25 | + * @param FileOptionBuilder $builder |
|
26 | + * |
|
27 | + * @return void |
|
28 | + */ |
|
29 | + public function __construct(Closure $callback, FileOptionBuilder $builder) |
|
30 | + { |
|
31 | 31 | $this->callback = $callback; |
32 | 32 | $this->builder = $builder; |
33 | - } |
|
33 | + } |
|
34 | 34 | |
35 | 35 | /** |
36 | 36 | * Sets the time in seconds. |
@@ -38,10 +38,10 @@ discard block |
||
38 | 38 | * @param int $seconds |
39 | 39 | * @return FileOptionBuilder|null |
40 | 40 | */ |
41 | - public function second(int $seconds): ?FileOptionBuilder |
|
42 | - { |
|
41 | + public function second(int $seconds): ?FileOptionBuilder |
|
42 | + { |
|
43 | 43 | return $this->setTime($seconds, "seconds"); |
44 | - } |
|
44 | + } |
|
45 | 45 | |
46 | 46 | /** |
47 | 47 | * Sets the time in minutes. |
@@ -49,10 +49,10 @@ discard block |
||
49 | 49 | * @param int $minutes |
50 | 50 | * @return FileOptionBuilder|null |
51 | 51 | */ |
52 | - public function minute(int $minutes): ?FileOptionBuilder |
|
53 | - { |
|
52 | + public function minute(int $minutes): ?FileOptionBuilder |
|
53 | + { |
|
54 | 54 | return $this->setTime($minutes, "minutes"); |
55 | - } |
|
55 | + } |
|
56 | 56 | |
57 | 57 | /** |
58 | 58 | * Sets the time in hours. |
@@ -60,10 +60,10 @@ discard block |
||
60 | 60 | * @param int $hours |
61 | 61 | * @return FileOptionBuilder|null |
62 | 62 | */ |
63 | - public function hour(int $hours): ?FileOptionBuilder |
|
64 | - { |
|
63 | + public function hour(int $hours): ?FileOptionBuilder |
|
64 | + { |
|
65 | 65 | return $this->setTime($hours, "hours"); |
66 | - } |
|
66 | + } |
|
67 | 67 | |
68 | 68 | /** |
69 | 69 | * Sets the time in days. |
@@ -71,10 +71,10 @@ discard block |
||
71 | 71 | * @param int $days |
72 | 72 | * @return FileOptionBuilder|null |
73 | 73 | */ |
74 | - public function day(int $days): ?FileOptionBuilder |
|
75 | - { |
|
74 | + public function day(int $days): ?FileOptionBuilder |
|
75 | + { |
|
76 | 76 | return $this->setTime($days, "days"); |
77 | - } |
|
77 | + } |
|
78 | 78 | |
79 | 79 | /** |
80 | 80 | * Sets the time in weeks. |
@@ -82,10 +82,10 @@ discard block |
||
82 | 82 | * @param int $weeks |
83 | 83 | * @return FileOptionBuilder|null |
84 | 84 | */ |
85 | - public function week(int $weeks): ?FileOptionBuilder |
|
86 | - { |
|
85 | + public function week(int $weeks): ?FileOptionBuilder |
|
86 | + { |
|
87 | 87 | return $this->setTime($weeks, "weeks"); |
88 | - } |
|
88 | + } |
|
89 | 89 | |
90 | 90 | /** |
91 | 91 | * Sets the time in months. |
@@ -93,10 +93,10 @@ discard block |
||
93 | 93 | * @param int $months |
94 | 94 | * @return FileOptionBuilder|null |
95 | 95 | */ |
96 | - public function month(int $months): ?FileOptionBuilder |
|
97 | - { |
|
96 | + public function month(int $months): ?FileOptionBuilder |
|
97 | + { |
|
98 | 98 | return $this->setTime($months, "months"); |
99 | - } |
|
99 | + } |
|
100 | 100 | |
101 | 101 | |
102 | 102 | /** |
@@ -106,10 +106,10 @@ discard block |
||
106 | 106 | * @param string $unit |
107 | 107 | * @return FileOptionBuilder|null |
108 | 108 | */ |
109 | - private function setTime(int $value, string $unit): ?FileOptionBuilder |
|
110 | - { |
|
111 | - ($this->callback)("{$value} {$unit}"); |
|
109 | + private function setTime(int $value, string $unit): ?FileOptionBuilder |
|
110 | + { |
|
111 | + ($this->callback)("{$value} {$unit}"); |
|
112 | 112 | return $this->builder; |
113 | - } |
|
113 | + } |
|
114 | 114 | |
115 | 115 | } |
@@ -20,8 +20,8 @@ discard block |
||
20 | 20 | { |
21 | 21 | |
22 | 22 | /** |
23 | - * @var Cacheer |
|
24 | - */ |
|
23 | + * @var Cacheer |
|
24 | + */ |
|
25 | 25 | protected Cacheer $cacheer; |
26 | 26 | |
27 | 27 | /** @param string $logPath */ |
@@ -38,10 +38,10 @@ discard block |
||
38 | 38 | } |
39 | 39 | |
40 | 40 | /** |
41 | - * Uses the database driver for caching. |
|
42 | - * |
|
43 | - * @return Cacheer |
|
44 | - */ |
|
41 | + * Uses the database driver for caching. |
|
42 | + * |
|
43 | + * @return Cacheer |
|
44 | + */ |
|
45 | 45 | public function useDatabaseDriver(): Cacheer |
46 | 46 | { |
47 | 47 | $this->cacheer->cacheStore = new DatabaseCacheStore($this->logPath); |
@@ -49,10 +49,10 @@ discard block |
||
49 | 49 | } |
50 | 50 | |
51 | 51 | /** |
52 | - * Uses the file driver for caching. |
|
53 | - * |
|
54 | - * @return Cacheer |
|
55 | - */ |
|
52 | + * Uses the file driver for caching. |
|
53 | + * |
|
54 | + * @return Cacheer |
|
55 | + */ |
|
56 | 56 | public function useFileDriver(): Cacheer |
57 | 57 | { |
58 | 58 | $this->cacheer->options['loggerPath'] = $this->logPath; |
@@ -61,10 +61,10 @@ discard block |
||
61 | 61 | } |
62 | 62 | |
63 | 63 | /** |
64 | - * Uses the Redis driver for caching. |
|
65 | - * |
|
66 | - * @return Cacheer |
|
67 | - */ |
|
64 | + * Uses the Redis driver for caching. |
|
65 | + * |
|
66 | + * @return Cacheer |
|
67 | + */ |
|
68 | 68 | public function useRedisDriver(): Cacheer |
69 | 69 | { |
70 | 70 | $this->cacheer->cacheStore = new RedisCacheStore($this->logPath); |
@@ -72,10 +72,10 @@ discard block |
||
72 | 72 | } |
73 | 73 | |
74 | 74 | /** |
75 | - * Uses the array driver for caching. |
|
76 | - * |
|
77 | - * @return Cacheer |
|
78 | - */ |
|
75 | + * Uses the array driver for caching. |
|
76 | + * |
|
77 | + * @return Cacheer |
|
78 | + */ |
|
79 | 79 | public function useArrayDriver(): Cacheer |
80 | 80 | { |
81 | 81 | $this->cacheer->cacheStore = new ArrayCacheStore($this->logPath); |
@@ -83,10 +83,10 @@ discard block |
||
83 | 83 | } |
84 | 84 | |
85 | 85 | /** |
86 | - * Uses the default driver for caching. |
|
87 | - * |
|
88 | - * @return Cacheer |
|
89 | - */ |
|
86 | + * Uses the default driver for caching. |
|
87 | + * |
|
88 | + * @return Cacheer |
|
89 | + */ |
|
90 | 90 | public function useDefaultDriver(): Cacheer |
91 | 91 | { |
92 | 92 | if (!isset($this->cacheer->options['cacheDir'])) { |
@@ -103,16 +103,16 @@ discard block |
||
103 | 103 | } |
104 | 104 | |
105 | 105 | /** |
106 | - * Checks if the directory exists or creates it. |
|
107 | - * |
|
108 | - * @param mixed $dirName |
|
109 | - * @return bool |
|
110 | - */ |
|
106 | + * Checks if the directory exists or creates it. |
|
107 | + * |
|
108 | + * @param mixed $dirName |
|
109 | + * @return bool |
|
110 | + */ |
|
111 | 111 | private function isDir(mixed $dirName): bool |
112 | 112 | { |
113 | - if (is_dir($dirName)) { |
|
114 | - return true; |
|
115 | - } |
|
116 | - return mkdir($dirName, 0755, true); |
|
113 | + if (is_dir($dirName)) { |
|
114 | + return true; |
|
115 | + } |
|
116 | + return mkdir($dirName, 0755, true); |
|
117 | 117 | } |
118 | 118 | } |
@@ -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; |
@@ -27,7 +27,7 @@ |
||
27 | 27 | * |
28 | 28 | * @return string|false |
29 | 29 | */ |
30 | - public function toJson(): bool|string |
|
30 | + public function toJson(): bool | string |
|
31 | 31 | { |
32 | 32 | return json_encode( |
33 | 33 | $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 | } |
@@ -20,7 +20,7 @@ |
||
20 | 20 | * @return float|int |
21 | 21 | * @throws CacheFileException |
22 | 22 | */ |
23 | - public static function convertExpirationToSeconds(string $expiration): float|int |
|
23 | + public static function convertExpirationToSeconds(string $expiration): float | int |
|
24 | 24 | { |
25 | 25 | $units = [ |
26 | 26 | 'second' => 1, |