@@ -71,7 +71,7 @@ discard block |
||
| 71 | 71 | /** |
| 72 | 72 | * Configuration des caches |
| 73 | 73 | */ |
| 74 | - protected array $config = []; |
|
| 74 | + protected array $config = [ ]; |
|
| 75 | 75 | |
| 76 | 76 | /** |
| 77 | 77 | * Adapter a utiliser pour la mise en cache |
@@ -81,7 +81,7 @@ discard block |
||
| 81 | 81 | /** |
| 82 | 82 | * Constructeur |
| 83 | 83 | */ |
| 84 | - public function __construct(array $config = []) |
|
| 84 | + public function __construct(array $config = [ ]) |
|
| 85 | 85 | { |
| 86 | 86 | $this->setConfig($config); |
| 87 | 87 | } |
@@ -102,51 +102,51 @@ discard block |
||
| 102 | 102 | */ |
| 103 | 103 | protected function factory(): CacheInterface |
| 104 | 104 | { |
| 105 | - if (! static::$_enabled) { |
|
| 105 | + if (!static::$_enabled) { |
|
| 106 | 106 | return new Dummy(); |
| 107 | 107 | } |
| 108 | - if (! empty($this->adapter)) { |
|
| 108 | + if (!empty($this->adapter)) { |
|
| 109 | 109 | return $this->adapter; |
| 110 | 110 | } |
| 111 | 111 | |
| 112 | - $validHandlers = $this->config['valid_handlers'] ?? self::$validHandlers; |
|
| 112 | + $validHandlers = $this->config[ 'valid_handlers' ] ?? self::$validHandlers; |
|
| 113 | 113 | |
| 114 | - if (empty($validHandlers) || ! is_array($validHandlers)) { |
|
| 114 | + if (empty($validHandlers) || !is_array($validHandlers)) { |
|
| 115 | 115 | throw new InvalidArgumentException('La configuration du cache doit avoir un tableau de $valid_handlers.'); |
| 116 | 116 | } |
| 117 | 117 | |
| 118 | - $handler = $this->config['handler'] ?? null; |
|
| 119 | - $fallback = $this->config['fallback_handler'] ?? null; |
|
| 118 | + $handler = $this->config[ 'handler' ] ?? null; |
|
| 119 | + $fallback = $this->config[ 'fallback_handler' ] ?? null; |
|
| 120 | 120 | |
| 121 | 121 | if (empty($handler)) { |
| 122 | 122 | throw new InvalidArgumentException('La configuration du cache doit avoir un ensemble de gestionnaires.'); |
| 123 | 123 | } |
| 124 | 124 | |
| 125 | - if (! array_key_exists($handler, $validHandlers)) { |
|
| 125 | + if (!array_key_exists($handler, $validHandlers)) { |
|
| 126 | 126 | throw new InvalidArgumentException('La configuration du cache a un gestionnaire non valide spécifié.'); |
| 127 | 127 | } |
| 128 | 128 | |
| 129 | - $adapter = new $validHandlers[$handler](); |
|
| 130 | - if (! ($adapter instanceof BaseHandler)) { |
|
| 129 | + $adapter = new $validHandlers[ $handler ](); |
|
| 130 | + if (!($adapter instanceof BaseHandler)) { |
|
| 131 | 131 | if (empty($fallback)) { |
| 132 | 132 | $adapter = new Dummy(); |
| 133 | - } elseif (! array_key_exists($fallback, $validHandlers)) { |
|
| 133 | + } elseif (!array_key_exists($fallback, $validHandlers)) { |
|
| 134 | 134 | throw new InvalidArgumentException('La configuration du cache a un gestionnaire de secours non valide spécifié.'); |
| 135 | 135 | } else { |
| 136 | - $adapter = new $validHandlers[$fallback](); |
|
| 136 | + $adapter = new $validHandlers[ $fallback ](); |
|
| 137 | 137 | } |
| 138 | 138 | } |
| 139 | 139 | |
| 140 | - if (! ($adapter instanceof BaseHandler)) { |
|
| 140 | + if (!($adapter instanceof BaseHandler)) { |
|
| 141 | 141 | throw new InvalidArgumentException('Le gestionnaire de cache doit utiliser BlitzPHP\Cache\Handlers\BaseHandler comme classe de base.'); |
| 142 | 142 | } |
| 143 | 143 | |
| 144 | - if (isset($this->config[$handler]) && is_array($this->config[$handler])) { |
|
| 145 | - $this->config = array_merge($this->config, $this->config[$handler]); |
|
| 146 | - unset($this->config[$handler]); |
|
| 144 | + if (isset($this->config[ $handler ]) && is_array($this->config[ $handler ])) { |
|
| 145 | + $this->config = array_merge($this->config, $this->config[ $handler ]); |
|
| 146 | + unset($this->config[ $handler ]); |
|
| 147 | 147 | } |
| 148 | 148 | |
| 149 | - if (! $adapter->init($this->config)) { |
|
| 149 | + if (!$adapter->init($this->config)) { |
|
| 150 | 150 | throw new RuntimeException( |
| 151 | 151 | sprintf( |
| 152 | 152 | 'Le moteur de cache %s n\'est pas correctement configuré. Consultez le journal des erreurs pour plus d\'informations.', |
@@ -176,7 +176,7 @@ discard block |
||
| 176 | 176 | * |
| 177 | 177 | * @return bool Vrai si les données ont été mises en cache avec succès, faux en cas d'échec |
| 178 | 178 | */ |
| 179 | - public function write(string $key, mixed $value, DateInterval|int|null $ttl = null): bool |
|
| 179 | + public function write(string $key, mixed $value, DateInterval | int | null $ttl = null): bool |
|
| 180 | 180 | { |
| 181 | 181 | if (is_resource($value)) { |
| 182 | 182 | return false; |
@@ -201,7 +201,7 @@ discard block |
||
| 201 | 201 | /** |
| 202 | 202 | * {@inheritDoc} |
| 203 | 203 | */ |
| 204 | - public function set(string $key, mixed $value, DateInterval|int|null $ttl = null): bool |
|
| 204 | + public function set(string $key, mixed $value, DateInterval | int | null $ttl = null): bool |
|
| 205 | 205 | { |
| 206 | 206 | return $this->write($key, $value, $ttl); |
| 207 | 207 | } |
@@ -226,7 +226,7 @@ discard block |
||
| 226 | 226 | * |
| 227 | 227 | * @throws InvalidArgumentException |
| 228 | 228 | */ |
| 229 | - public function writeMany(iterable $data, DateInterval|int|null $ttl = null): bool |
|
| 229 | + public function writeMany(iterable $data, DateInterval | int | null $ttl = null): bool |
|
| 230 | 230 | { |
| 231 | 231 | return $this->factory()->setMultiple($data, $ttl); |
| 232 | 232 | } |
@@ -234,7 +234,7 @@ discard block |
||
| 234 | 234 | /** |
| 235 | 235 | * {@inheritDoc} |
| 236 | 236 | */ |
| 237 | - public function setMultiple(iterable $values, DateInterval|int|null $ttl = null): bool |
|
| 237 | + public function setMultiple(iterable $values, DateInterval | int | null $ttl = null): bool |
|
| 238 | 238 | { |
| 239 | 239 | return $this->writeMany($values, $ttl); |
| 240 | 240 | } |
@@ -452,7 +452,7 @@ discard block |
||
| 452 | 452 | * @return mixed Si la clé est trouvée : les données en cache. |
| 453 | 453 | * Si la clé n'est pas trouvée, la valeur renvoyée par le callable. |
| 454 | 454 | */ |
| 455 | - public function remember(string $key, callable|DateInterval|int|null $ttl, callable $callable): mixed |
|
| 455 | + public function remember(string $key, callable | DateInterval | int | null $ttl, callable $callable): mixed |
|
| 456 | 456 | { |
| 457 | 457 | if (is_callable($ttl)) { |
| 458 | 458 | $callable = $ttl; |