@@ -451,7 +451,7 @@ |
||
451 | 451 | |
452 | 452 | // la désactivation des itérateurs permet de libérer d'éventuels verrous dans certains environnements, |
453 | 453 | // qui pourrait autrement faire échouer `rmdir()` |
454 | - unset($directoryIterator, $contents, $filtered); |
|
454 | + unset($directoryIterator, $contents, $filtered); |
|
455 | 455 | |
456 | 456 | return true; |
457 | 457 | } |
@@ -48,7 +48,7 @@ discard block |
||
48 | 48 | */ |
49 | 49 | protected array $_defaultConfig = [ |
50 | 50 | 'duration' => 3600, |
51 | - 'groups' => [], |
|
51 | + 'groups' => [ ], |
|
52 | 52 | 'lock' => true, |
53 | 53 | 'mask' => 0664, |
54 | 54 | 'path' => null, |
@@ -64,15 +64,15 @@ discard block |
||
64 | 64 | /** |
65 | 65 | * {@inheritDoc} |
66 | 66 | */ |
67 | - public function init(array $config = []): bool |
|
67 | + public function init(array $config = [ ]): bool |
|
68 | 68 | { |
69 | 69 | parent::init($config); |
70 | 70 | |
71 | - if ($this->_config['path'] === null) { |
|
72 | - $this->_config['path'] = sys_get_temp_dir() . DIRECTORY_SEPARATOR . 'blitz-php' . DIRECTORY_SEPARATOR . 'cache' . DIRECTORY_SEPARATOR; |
|
71 | + if ($this->_config[ 'path' ] === null) { |
|
72 | + $this->_config[ 'path' ] = sys_get_temp_dir().DIRECTORY_SEPARATOR.'blitz-php'.DIRECTORY_SEPARATOR.'cache'.DIRECTORY_SEPARATOR; |
|
73 | 73 | } |
74 | - if (substr($this->_config['path'], -1) !== DIRECTORY_SEPARATOR) { |
|
75 | - $this->_config['path'] .= DIRECTORY_SEPARATOR; |
|
74 | + if (substr($this->_config[ 'path' ], -1) !== DIRECTORY_SEPARATOR) { |
|
75 | + $this->_config[ 'path' ] .= DIRECTORY_SEPARATOR; |
|
76 | 76 | } |
77 | 77 | if ($this->_groupPrefix) { |
78 | 78 | $this->_groupPrefix = str_replace('_', DIRECTORY_SEPARATOR, $this->_groupPrefix); |
@@ -84,9 +84,9 @@ discard block |
||
84 | 84 | /** |
85 | 85 | * {@inheritDoc} |
86 | 86 | */ |
87 | - public function set(string $key, mixed $value, DateInterval|int|null $ttl = null): bool |
|
87 | + public function set(string $key, mixed $value, DateInterval | int | null $ttl = null): bool |
|
88 | 88 | { |
89 | - if ($value === '' || ! $this->_init) { |
|
89 | + if ($value === '' || !$this->_init) { |
|
90 | 90 | return false; |
91 | 91 | } |
92 | 92 | |
@@ -96,14 +96,14 @@ discard block |
||
96 | 96 | return false; |
97 | 97 | } |
98 | 98 | |
99 | - if (! empty($this->_config['serialize'])) { |
|
99 | + if (!empty($this->_config[ 'serialize' ])) { |
|
100 | 100 | $value = serialize($value); |
101 | 101 | } |
102 | 102 | |
103 | 103 | $expires = time() + $this->duration($ttl); |
104 | - $contents = implode('', [$expires, PHP_EOL, $value, PHP_EOL]); |
|
104 | + $contents = implode('', [ $expires, PHP_EOL, $value, PHP_EOL ]); |
|
105 | 105 | |
106 | - if ($this->_config['lock']) { |
|
106 | + if ($this->_config[ 'lock' ]) { |
|
107 | 107 | /** @psalm-suppress PossiblyNullReference */ |
108 | 108 | $this->_File->flock(LOCK_EX); |
109 | 109 | } |
@@ -114,7 +114,7 @@ discard block |
||
114 | 114 | && $this->_File->fwrite($contents) |
115 | 115 | && $this->_File->fflush(); |
116 | 116 | |
117 | - if ($this->_config['lock']) { |
|
117 | + if ($this->_config[ 'lock' ]) { |
|
118 | 118 | $this->_File->flock(LOCK_UN); |
119 | 119 | } |
120 | 120 | $this->_File = null; |
@@ -129,11 +129,11 @@ discard block |
||
129 | 129 | { |
130 | 130 | $key = $this->_key($key); |
131 | 131 | |
132 | - if (! $this->_init || $this->_setKey($key) === false) { |
|
132 | + if (!$this->_init || $this->_setKey($key) === false) { |
|
133 | 133 | return $default; |
134 | 134 | } |
135 | 135 | |
136 | - if ($this->_config['lock']) { |
|
136 | + if ($this->_config[ 'lock' ]) { |
|
137 | 137 | /** @psalm-suppress PossiblyNullReference */ |
138 | 138 | $this->_File->flock(LOCK_SH); |
139 | 139 | } |
@@ -144,7 +144,7 @@ discard block |
||
144 | 144 | $cachetime = (int) $this->_File->current(); |
145 | 145 | |
146 | 146 | if ($cachetime < $time) { |
147 | - if ($this->_config['lock']) { |
|
147 | + if ($this->_config[ 'lock' ]) { |
|
148 | 148 | $this->_File->flock(LOCK_UN); |
149 | 149 | } |
150 | 150 | |
@@ -160,13 +160,13 @@ discard block |
||
160 | 160 | $this->_File->next(); |
161 | 161 | } |
162 | 162 | |
163 | - if ($this->_config['lock']) { |
|
163 | + if ($this->_config[ 'lock' ]) { |
|
164 | 164 | $this->_File->flock(LOCK_UN); |
165 | 165 | } |
166 | 166 | |
167 | 167 | $data = trim($data); |
168 | 168 | |
169 | - if ($data !== '' && ! empty($this->_config['serialize'])) { |
|
169 | + if ($data !== '' && !empty($this->_config[ 'serialize' ])) { |
|
170 | 170 | $data = unserialize($data); |
171 | 171 | } |
172 | 172 | |
@@ -180,7 +180,7 @@ discard block |
||
180 | 180 | { |
181 | 181 | $key = $this->_key($key); |
182 | 182 | |
183 | - if ($this->_setKey($key) === false || ! $this->_init) { |
|
183 | + if ($this->_setKey($key) === false || !$this->_init) { |
|
184 | 184 | return false; |
185 | 185 | } |
186 | 186 | |
@@ -202,22 +202,22 @@ discard block |
||
202 | 202 | */ |
203 | 203 | public function clear(): bool |
204 | 204 | { |
205 | - if (! $this->_init) { |
|
205 | + if (!$this->_init) { |
|
206 | 206 | return false; |
207 | 207 | } |
208 | 208 | $this->_File = null; |
209 | 209 | |
210 | - $this->_clearDirectory($this->_config['path']); |
|
210 | + $this->_clearDirectory($this->_config[ 'path' ]); |
|
211 | 211 | |
212 | 212 | $directory = new RecursiveDirectoryIterator( |
213 | - $this->_config['path'], |
|
213 | + $this->_config[ 'path' ], |
|
214 | 214 | FilesystemIterator::SKIP_DOTS |
215 | 215 | ); |
216 | 216 | $contents = new RecursiveIteratorIterator( |
217 | 217 | $directory, |
218 | 218 | RecursiveIteratorIterator::SELF_FIRST |
219 | 219 | ); |
220 | - $cleared = []; |
|
220 | + $cleared = [ ]; |
|
221 | 221 | /** @var SplFileInfo $fileInfo */ |
222 | 222 | foreach ($contents as $fileInfo) { |
223 | 223 | if ($fileInfo->isFile()) { |
@@ -227,16 +227,16 @@ discard block |
||
227 | 227 | } |
228 | 228 | |
229 | 229 | $realPath = $fileInfo->getRealPath(); |
230 | - if (! $realPath) { |
|
230 | + if (!$realPath) { |
|
231 | 231 | unset($fileInfo); |
232 | 232 | |
233 | 233 | continue; |
234 | 234 | } |
235 | 235 | |
236 | - $path = $realPath . DIRECTORY_SEPARATOR; |
|
237 | - if (! in_array($path, $cleared, true)) { |
|
236 | + $path = $realPath.DIRECTORY_SEPARATOR; |
|
237 | + if (!in_array($path, $cleared, true)) { |
|
238 | 238 | $this->_clearDirectory($path); |
239 | - $cleared[] = $path; |
|
239 | + $cleared[ ] = $path; |
|
240 | 240 | } |
241 | 241 | |
242 | 242 | // les itérateurs internes possibles doivent également être désactivés pour que les verrous sur les parents soient libérés |
@@ -255,24 +255,24 @@ discard block |
||
255 | 255 | */ |
256 | 256 | protected function _clearDirectory(string $path): void |
257 | 257 | { |
258 | - if (! is_dir($path)) { |
|
258 | + if (!is_dir($path)) { |
|
259 | 259 | return; |
260 | 260 | } |
261 | 261 | |
262 | 262 | $dir = dir($path); |
263 | - if (! $dir) { |
|
263 | + if (!$dir) { |
|
264 | 264 | return; |
265 | 265 | } |
266 | 266 | |
267 | - $prefixLength = strlen($this->_config['prefix']); |
|
267 | + $prefixLength = strlen($this->_config[ 'prefix' ]); |
|
268 | 268 | |
269 | 269 | while (($entry = $dir->read()) !== false) { |
270 | - if (substr($entry, 0, $prefixLength) !== $this->_config['prefix']) { |
|
270 | + if (substr($entry, 0, $prefixLength) !== $this->_config[ 'prefix' ]) { |
|
271 | 271 | continue; |
272 | 272 | } |
273 | 273 | |
274 | 274 | try { |
275 | - $file = new SplFileObject($path . $entry, 'r'); |
|
275 | + $file = new SplFileObject($path.$entry, 'r'); |
|
276 | 276 | } catch (Exception $e) { |
277 | 277 | continue; |
278 | 278 | } |
@@ -324,15 +324,15 @@ discard block |
||
324 | 324 | if ($this->_groupPrefix) { |
325 | 325 | $groups = vsprintf($this->_groupPrefix, $this->groups()); |
326 | 326 | } |
327 | - $dir = $this->_config['path'] . $groups; |
|
327 | + $dir = $this->_config[ 'path' ].$groups; |
|
328 | 328 | |
329 | - if (! is_dir($dir)) { |
|
329 | + if (!is_dir($dir)) { |
|
330 | 330 | mkdir($dir, 0775, true); |
331 | 331 | } |
332 | 332 | |
333 | - $path = new SplFileInfo($dir . $key); |
|
333 | + $path = new SplFileInfo($dir.$key); |
|
334 | 334 | |
335 | - if (! $createKey && ! $path->isFile()) { |
|
335 | + if (!$createKey && !$path->isFile()) { |
|
336 | 336 | return false; |
337 | 337 | } |
338 | 338 | if ( |
@@ -351,11 +351,11 @@ discard block |
||
351 | 351 | } |
352 | 352 | unset($path); |
353 | 353 | |
354 | - if (! $exists && ! chmod($this->_File->getPathname(), (int) $this->_config['mask'])) { |
|
354 | + if (!$exists && !chmod($this->_File->getPathname(), (int) $this->_config[ 'mask' ])) { |
|
355 | 355 | trigger_error(sprintf( |
356 | 356 | 'Impossible d\'appliquer le masque d\'autorisation "%s" sur le fichier cache "%s"', |
357 | 357 | $this->_File->getPathname(), |
358 | - $this->_config['mask'] |
|
358 | + $this->_config[ 'mask' ] |
|
359 | 359 | ), E_USER_WARNING); |
360 | 360 | } |
361 | 361 | } |
@@ -368,21 +368,21 @@ discard block |
||
368 | 368 | */ |
369 | 369 | protected function _active(): bool |
370 | 370 | { |
371 | - $dir = new SplFileInfo($this->_config['path']); |
|
371 | + $dir = new SplFileInfo($this->_config[ 'path' ]); |
|
372 | 372 | $path = $dir->getPathname(); |
373 | 373 | $success = true; |
374 | - if (! is_dir($path)) { |
|
374 | + if (!is_dir($path)) { |
|
375 | 375 | // phpcs:disable |
376 | 376 | $success = @mkdir($path, 0775, true); |
377 | 377 | // phpcs:enable |
378 | 378 | } |
379 | 379 | |
380 | 380 | $isWritableDir = ($dir->isDir() && $dir->isWritable()); |
381 | - if (! $success || ($this->_init && ! $isWritableDir)) { |
|
381 | + if (!$success || ($this->_init && !$isWritableDir)) { |
|
382 | 382 | $this->_init = false; |
383 | 383 | trigger_error(sprintf( |
384 | 384 | '%s is not writable', |
385 | - $this->_config['path'] |
|
385 | + $this->_config[ 'path' ] |
|
386 | 386 | ), E_USER_WARNING); |
387 | 387 | } |
388 | 388 | |
@@ -398,7 +398,7 @@ discard block |
||
398 | 398 | |
399 | 399 | if (preg_match('/[\/\\<>?:|*"]/', $key)) { |
400 | 400 | throw new InvalidArgumentException( |
401 | - "La clé de cache `{$key}` contient des caractères non valides. " . |
|
401 | + "La clé de cache `{$key}` contient des caractères non valides. ". |
|
402 | 402 | 'Vous ne pouvez pas utiliser /, \\, <, >, ?, :, |, * ou " dans les clés de cache.' |
403 | 403 | ); |
404 | 404 | } |
@@ -413,17 +413,17 @@ discard block |
||
413 | 413 | { |
414 | 414 | $this->_File = null; |
415 | 415 | |
416 | - $prefix = (string) $this->_config['prefix']; |
|
416 | + $prefix = (string) $this->_config[ 'prefix' ]; |
|
417 | 417 | |
418 | - $directoryIterator = new RecursiveDirectoryIterator($this->_config['path']); |
|
418 | + $directoryIterator = new RecursiveDirectoryIterator($this->_config[ 'path' ]); |
|
419 | 419 | $contents = new RecursiveIteratorIterator( |
420 | 420 | $directoryIterator, |
421 | 421 | RecursiveIteratorIterator::CHILD_FIRST |
422 | 422 | ); |
423 | 423 | $filtered = new CallbackFilterIterator( |
424 | 424 | $contents, |
425 | - static function (SplFileInfo $current) use ($group, $prefix) { |
|
426 | - if (! $current->isFile()) { |
|
425 | + static function(SplFileInfo $current) use ($group, $prefix) { |
|
426 | + if (!$current->isFile()) { |
|
427 | 427 | return false; |
428 | 428 | } |
429 | 429 | |
@@ -435,7 +435,7 @@ discard block |
||
435 | 435 | |
436 | 436 | $pos = strpos( |
437 | 437 | $current->getPathname(), |
438 | - DIRECTORY_SEPARATOR . $group . DIRECTORY_SEPARATOR |
|
438 | + DIRECTORY_SEPARATOR.$group.DIRECTORY_SEPARATOR |
|
439 | 439 | ); |
440 | 440 | |
441 | 441 | return $pos !== false; |
@@ -31,7 +31,7 @@ discard block |
||
31 | 31 | /** |
32 | 32 | * {@inheritDoc} |
33 | 33 | */ |
34 | - public function init(array $config = []): bool |
|
34 | + public function init(array $config = [ ]): bool |
|
35 | 35 | { |
36 | 36 | return true; |
37 | 37 | } |
@@ -39,7 +39,7 @@ discard block |
||
39 | 39 | /** |
40 | 40 | * {@inheritDoc} |
41 | 41 | */ |
42 | - public function set(string $key, mixed $value, DateInterval|int|null $ttl = null): bool |
|
42 | + public function set(string $key, mixed $value, DateInterval | int | null $ttl = null): bool |
|
43 | 43 | { |
44 | 44 | return true; |
45 | 45 | } |
@@ -47,7 +47,7 @@ discard block |
||
47 | 47 | /** |
48 | 48 | * {@inheritDoc} |
49 | 49 | */ |
50 | - public function setMultiple(iterable $values, DateInterval|int|null $ttl = null): bool |
|
50 | + public function setMultiple(iterable $values, DateInterval | int | null $ttl = null): bool |
|
51 | 51 | { |
52 | 52 | return true; |
53 | 53 | } |
@@ -65,7 +65,7 @@ discard block |
||
65 | 65 | */ |
66 | 66 | public function getMultiple(iterable $keys, mixed $default = null): iterable |
67 | 67 | { |
68 | - return []; |
|
68 | + return [ ]; |
|
69 | 69 | } |
70 | 70 | |
71 | 71 | /** |
@@ -410,6 +410,6 @@ |
||
410 | 410 | return $ttl; |
411 | 411 | } |
412 | 412 | |
413 | - return (int) $ttl->format('%s'); |
|
413 | + return (int) $ttl->format('%s'); |
|
414 | 414 | } |
415 | 415 | } |
@@ -60,7 +60,7 @@ discard block |
||
60 | 60 | */ |
61 | 61 | protected array $_defaultConfig = [ |
62 | 62 | 'duration' => 3600, |
63 | - 'groups' => [], |
|
63 | + 'groups' => [ ], |
|
64 | 64 | 'prefix' => 'blitz_', |
65 | 65 | 'warnOnWriteFailures' => true, |
66 | 66 | ]; |
@@ -81,16 +81,16 @@ discard block |
||
81 | 81 | * |
82 | 82 | * @return bool Vrai si le moteur a été initialisé avec succès, faux sinon |
83 | 83 | */ |
84 | - public function init(array $config = []): bool |
|
84 | + public function init(array $config = [ ]): bool |
|
85 | 85 | { |
86 | 86 | $this->setConfig($config); |
87 | 87 | |
88 | - if (! empty($this->_config['groups'])) { |
|
89 | - sort($this->_config['groups']); |
|
90 | - $this->_groupPrefix = str_repeat('%s_', count($this->_config['groups'])); |
|
88 | + if (!empty($this->_config[ 'groups' ])) { |
|
89 | + sort($this->_config[ 'groups' ]); |
|
90 | + $this->_groupPrefix = str_repeat('%s_', count($this->_config[ 'groups' ])); |
|
91 | 91 | } |
92 | - if (! is_numeric($this->_config['duration'])) { |
|
93 | - $this->_config['duration'] = strtotime($this->_config['duration']) - time(); |
|
92 | + if (!is_numeric($this->_config[ 'duration' ])) { |
|
93 | + $this->_config[ 'duration' ] = strtotime($this->_config[ 'duration' ]) - time(); |
|
94 | 94 | } |
95 | 95 | |
96 | 96 | return true; |
@@ -111,13 +111,13 @@ discard block |
||
111 | 111 | */ |
112 | 112 | public function ensureValidKey(string $key): void |
113 | 113 | { |
114 | - if (! is_string($key) || $key === '') { |
|
114 | + if (!is_string($key) || $key === '') { |
|
115 | 115 | throw new InvalidArgumentException('Une clé de cache doit être une chaîne non vide.'); |
116 | 116 | } |
117 | 117 | |
118 | 118 | $reserved = self::$reservedCharacters; |
119 | 119 | if ($reserved && strpbrk($key, $reserved) !== false) { |
120 | - throw new InvalidArgumentException('La clé de cache contient des caractères réservés ' . $reserved); |
|
120 | + throw new InvalidArgumentException('La clé de cache contient des caractères réservés '.$reserved); |
|
121 | 121 | } |
122 | 122 | } |
123 | 123 | |
@@ -131,7 +131,7 @@ discard block |
||
131 | 131 | */ |
132 | 132 | protected function ensureValidType($iterable, string $check = self::CHECK_VALUE): void |
133 | 133 | { |
134 | - if (! is_iterable($iterable)) { |
|
134 | + if (!is_iterable($iterable)) { |
|
135 | 135 | throw new InvalidArgumentException(sprintf( |
136 | 136 | 'Un cache %s doit être soit un tableau soit un Traversable.', |
137 | 137 | $check === self::CHECK_VALUE ? 'key set' : 'set' |
@@ -192,10 +192,10 @@ discard block |
||
192 | 192 | { |
193 | 193 | $this->ensureValidType($keys); |
194 | 194 | |
195 | - $results = []; |
|
195 | + $results = [ ]; |
|
196 | 196 | |
197 | 197 | foreach ($keys as $key) { |
198 | - $results[$key] = $this->get($key, $default); |
|
198 | + $results[ $key ] = $this->get($key, $default); |
|
199 | 199 | } |
200 | 200 | |
201 | 201 | return $results; |
@@ -214,7 +214,7 @@ discard block |
||
214 | 214 | * @throws InvalidArgumentException Si $values n'est ni un tableau ni un Traversable, |
215 | 215 | * ou si l'une des valeurs $ n'est pas une valeur légale. |
216 | 216 | */ |
217 | - public function setMultiple(iterable $values, DateInterval|int|null $ttl = null): bool |
|
217 | + public function setMultiple(iterable $values, DateInterval | int | null $ttl = null): bool |
|
218 | 218 | { |
219 | 219 | $this->ensureValidType($values, self::CHECK_KEY); |
220 | 220 | |
@@ -260,7 +260,7 @@ discard block |
||
260 | 260 | $result = true; |
261 | 261 | |
262 | 262 | foreach ($keys as $key) { |
263 | - if (! $this->delete($key)) { |
|
263 | + if (!$this->delete($key)) { |
|
264 | 264 | $result = false; |
265 | 265 | } |
266 | 266 | } |
@@ -304,7 +304,7 @@ discard block |
||
304 | 304 | * |
305 | 305 | * @return bool Vrai en cas de succès et faux en cas d'échec. |
306 | 306 | */ |
307 | - abstract public function set(string $key, mixed $value, DateInterval|int|null $ttl = null): bool; |
|
307 | + abstract public function set(string $key, mixed $value, DateInterval | int | null $ttl = null): bool; |
|
308 | 308 | |
309 | 309 | /** |
310 | 310 | * {@inheritDoc} |
@@ -353,7 +353,7 @@ discard block |
||
353 | 353 | */ |
354 | 354 | public function groups(): array |
355 | 355 | { |
356 | - return $this->_config['groups']; |
|
356 | + return $this->_config[ 'groups' ]; |
|
357 | 357 | } |
358 | 358 | |
359 | 359 | /** |
@@ -378,7 +378,7 @@ discard block |
||
378 | 378 | } |
379 | 379 | $key = preg_replace('/[\s]+/', '_', $key); |
380 | 380 | |
381 | - return $this->_config['prefix'] . $prefix . $key; |
|
381 | + return $this->_config[ 'prefix' ].$prefix.$key; |
|
382 | 382 | } |
383 | 383 | |
384 | 384 | /** |
@@ -400,10 +400,10 @@ discard block |
||
400 | 400 | * @param DateInterval|int|null $ttl La valeur TTL de cet élément. Si null est envoyé, |
401 | 401 | * La durée par défaut du conducteur sera utilisée. |
402 | 402 | */ |
403 | - protected function duration(DateInterval|int|null $ttl): int |
|
403 | + protected function duration(DateInterval | int | null $ttl): int |
|
404 | 404 | { |
405 | 405 | if ($ttl === null) { |
406 | - return $this->_config['duration']; |
|
406 | + return $this->_config[ 'duration' ]; |
|
407 | 407 | } |
408 | 408 | |
409 | 409 | if (is_int($ttl)) { |
@@ -66,7 +66,7 @@ discard block |
||
66 | 66 | /** |
67 | 67 | * Configuration des caches |
68 | 68 | */ |
69 | - protected array $config = []; |
|
69 | + protected array $config = [ ]; |
|
70 | 70 | |
71 | 71 | /** |
72 | 72 | * Adapter a utiliser pour la mise en cache |
@@ -76,7 +76,7 @@ discard block |
||
76 | 76 | /** |
77 | 77 | * Constructeur |
78 | 78 | */ |
79 | - public function __construct(array $config = []) |
|
79 | + public function __construct(array $config = [ ]) |
|
80 | 80 | { |
81 | 81 | $this->setConfig($config); |
82 | 82 | } |
@@ -97,46 +97,46 @@ discard block |
||
97 | 97 | */ |
98 | 98 | protected function factory(): CacheInterface |
99 | 99 | { |
100 | - if (! static::$_enabled) { |
|
100 | + if (!static::$_enabled) { |
|
101 | 101 | return new Dummy(); |
102 | 102 | } |
103 | - if (! empty($this->adapter)) { |
|
103 | + if (!empty($this->adapter)) { |
|
104 | 104 | return $this->adapter; |
105 | 105 | } |
106 | 106 | |
107 | - $validHandlers = $this->config['valid_handlers'] ?? self::$validHandlers; |
|
107 | + $validHandlers = $this->config[ 'valid_handlers' ] ?? self::$validHandlers; |
|
108 | 108 | |
109 | - if (empty($validHandlers) || ! is_array($validHandlers)) { |
|
109 | + if (empty($validHandlers) || !is_array($validHandlers)) { |
|
110 | 110 | throw new InvalidArgumentException('La configuration du cache doit avoir un tableau de $valid_handlers.'); |
111 | 111 | } |
112 | 112 | |
113 | - $handler = $this->config['handler'] ?? null; |
|
114 | - $fallback = $this->config['fallback_handler'] ?? null; |
|
113 | + $handler = $this->config[ 'handler' ] ?? null; |
|
114 | + $fallback = $this->config[ 'fallback_handler' ] ?? null; |
|
115 | 115 | |
116 | 116 | if (empty($handler)) { |
117 | 117 | throw new InvalidArgumentException('La configuration du cache doit avoir un ensemble de gestionnaires.'); |
118 | 118 | } |
119 | 119 | |
120 | - if (! array_key_exists($handler, $validHandlers)) { |
|
120 | + if (!array_key_exists($handler, $validHandlers)) { |
|
121 | 121 | throw new InvalidArgumentException('La configuration du cache a un gestionnaire non valide spécifié.'); |
122 | 122 | } |
123 | 123 | |
124 | - $adapter = new $validHandlers[$handler](); |
|
125 | - if (! ($adapter instanceof BaseHandler)) { |
|
124 | + $adapter = new $validHandlers[ $handler ](); |
|
125 | + if (!($adapter instanceof BaseHandler)) { |
|
126 | 126 | if (empty($fallback)) { |
127 | 127 | $adapter = new Dummy(); |
128 | - } elseif (! array_key_exists($fallback, $validHandlers)) { |
|
128 | + } elseif (!array_key_exists($fallback, $validHandlers)) { |
|
129 | 129 | throw new InvalidArgumentException('La configuration du cache a un gestionnaire de secours non valide spécifié.'); |
130 | 130 | } else { |
131 | - $adapter = new $validHandlers[$fallback](); |
|
131 | + $adapter = new $validHandlers[ $fallback ](); |
|
132 | 132 | } |
133 | 133 | } |
134 | 134 | |
135 | - if (! ($adapter instanceof BaseHandler)) { |
|
135 | + if (!($adapter instanceof BaseHandler)) { |
|
136 | 136 | throw new InvalidArgumentException('Le gestionnaire de cache doit utiliser BlitzPHP\Cache\Handlers\BaseHandler comme classe de base.'); |
137 | 137 | } |
138 | 138 | |
139 | - if (! $adapter->init($this->config)) { |
|
139 | + if (!$adapter->init($this->config)) { |
|
140 | 140 | throw new RuntimeException( |
141 | 141 | sprintf( |
142 | 142 | 'Le moteur de cache %s n\'est pas correctement configuré. Consultez le journal des erreurs pour plus d\'informations.', |
@@ -166,7 +166,7 @@ discard block |
||
166 | 166 | * |
167 | 167 | * @return bool Vrai si les données ont été mises en cache avec succès, faux en cas d'échec |
168 | 168 | */ |
169 | - public function write(string $key, mixed $value, DateInterval|int|null $ttl = null): bool |
|
169 | + public function write(string $key, mixed $value, DateInterval | int | null $ttl = null): bool |
|
170 | 170 | { |
171 | 171 | if (is_resource($value)) { |
172 | 172 | return false; |
@@ -191,7 +191,7 @@ discard block |
||
191 | 191 | /** |
192 | 192 | * {@inheritDoc} |
193 | 193 | */ |
194 | - public function set(string $key, mixed $value, DateInterval|int|null $ttl = null): bool |
|
194 | + public function set(string $key, mixed $value, DateInterval | int | null $ttl = null): bool |
|
195 | 195 | { |
196 | 196 | return $this->write($key, $value, $ttl); |
197 | 197 | } |
@@ -216,7 +216,7 @@ discard block |
||
216 | 216 | * |
217 | 217 | * @throws InvalidArgumentException |
218 | 218 | */ |
219 | - public function writeMany(iterable $data, DateInterval|int|null $ttl = null): bool |
|
219 | + public function writeMany(iterable $data, DateInterval | int | null $ttl = null): bool |
|
220 | 220 | { |
221 | 221 | return $this->factory()->setMultiple($data, $ttl); |
222 | 222 | } |
@@ -224,7 +224,7 @@ discard block |
||
224 | 224 | /** |
225 | 225 | * {@inheritDoc} |
226 | 226 | */ |
227 | - public function setMultiple(iterable $values, DateInterval|int|null $ttl = null): bool |
|
227 | + public function setMultiple(iterable $values, DateInterval | int | null $ttl = null): bool |
|
228 | 228 | { |
229 | 229 | return $this->writeMany($values, $ttl); |
230 | 230 | } |