Passed
Push — main ( 4fdfef...ddb583 )
by Dimitri
11:51
created
Cache.php 2 patches
Indentation   +20 added lines, -20 removed lines patch added patch discarded remove patch
@@ -100,8 +100,8 @@  discard block
 block discarded – undo
100 100
 
101 101
     /**
102 102
      * Tente de créer le gestionnaire de cache souhaité
103
-	 *
104
-	 * @return BaseHandler
103
+     *
104
+     * @return BaseHandler
105 105
      */
106 106
     protected function factory(): CacheInterface
107 107
     {
@@ -251,7 +251,7 @@  discard block
 block discarded – undo
251 251
      *
252 252
      * ```
253 253
      * $cache->read('my_data');
254
-	 * ```
254
+     * ```
255 255
      */
256 256
     public function read(string $key, mixed $default = null): mixed
257 257
     {
@@ -290,7 +290,7 @@  discard block
 block discarded – undo
290 290
      *
291 291
      * ```
292 292
      * $cache->readMany(['my_data_1', 'my_data_2']);
293
-	 * ```
293
+     * ```
294 294
      */
295 295
     public function readMany(iterable $keys, mixed $default = null): iterable
296 296
     {
@@ -529,14 +529,14 @@  discard block
 block discarded – undo
529 529
         return $this->factory()->has($key);
530 530
     }
531 531
 
532
-	/**
533
-     * Récupérez un élément du cache et supprimez-le.
534
-     *
535
-     * @template TCacheValue
536
-     *
537
-     * @param  TCacheValue|(\Closure(): TCacheValue)  $default
538
-     * @return (TCacheValue is null ? mixed : TCacheValue)
539
-     */
532
+ /**
533
+  * Récupérez un élément du cache et supprimez-le.
534
+  *
535
+  * @template TCacheValue
536
+  *
537
+  * @param  TCacheValue|(\Closure(): TCacheValue)  $default
538
+  * @return (TCacheValue is null ? mixed : TCacheValue)
539
+  */
540 540
     public function pull(string $key, $default = null)
541 541
     {
542 542
         return Helpers::tap($this->read($key, $default), function () use ($key) {
@@ -544,14 +544,14 @@  discard block
 block discarded – undo
544 544
         });
545 545
     }
546 546
 
547
-	/**
548
-     * Récupérez un élément du cache et supprimez-le.
549
-     *
550
-     * @template TCacheValue
551
-     *
552
-     * @param  TCacheValue|(\Closure(): TCacheValue)  $default
553
-     * @return (TCacheValue is null ? mixed : TCacheValue)
554
-     */
547
+ /**
548
+  * Récupérez un élément du cache et supprimez-le.
549
+  *
550
+  * @template TCacheValue
551
+  *
552
+  * @param  TCacheValue|(\Closure(): TCacheValue)  $default
553
+  * @return (TCacheValue is null ? mixed : TCacheValue)
554
+  */
555 555
     public function pullMany(iterable $keys, $default = null)
556 556
     {
557 557
         return Helpers::tap($this->readMany($keys, $default), function () use ($keys) {
Please login to merge, or discard this patch.
Spacing   +25 added lines, -25 removed lines patch added patch discarded remove patch
@@ -72,7 +72,7 @@  discard block
 block discarded – undo
72 72
     /**
73 73
      * Configuration des caches
74 74
      */
75
-    protected array $config = [];
75
+    protected array $config = [ ];
76 76
 
77 77
     /**
78 78
      * Adapter a utiliser pour la mise en cache
@@ -82,7 +82,7 @@  discard block
 block discarded – undo
82 82
     /**
83 83
      * Constructeur
84 84
      */
85
-    public function __construct(array $config = [])
85
+    public function __construct(array $config = [ ])
86 86
     {
87 87
         $this->setConfig($config);
88 88
     }
@@ -105,51 +105,51 @@  discard block
 block discarded – undo
105 105
      */
106 106
     protected function factory(): CacheInterface
107 107
     {
108
-        if (! static::$_enabled) {
108
+        if (!static::$_enabled) {
109 109
             return new Dummy();
110 110
         }
111
-        if (! empty($this->adapter)) {
111
+        if (!empty($this->adapter)) {
112 112
             return $this->adapter;
113 113
         }
114 114
 
115
-        $validHandlers = $this->config['valid_handlers'] ?? self::$validHandlers;
115
+        $validHandlers = $this->config[ 'valid_handlers' ] ?? self::$validHandlers;
116 116
 
117
-        if (empty($validHandlers) || ! is_array($validHandlers)) {
117
+        if (empty($validHandlers) || !is_array($validHandlers)) {
118 118
             throw new InvalidArgumentException('La configuration du cache doit avoir un tableau de $valid_handlers.');
119 119
         }
120 120
 
121
-        $handler  = $this->config['handler'] ?? null;
122
-        $fallback = $this->config['fallback_handler'] ?? null;
121
+        $handler  = $this->config[ 'handler' ] ?? null;
122
+        $fallback = $this->config[ 'fallback_handler' ] ?? null;
123 123
 
124 124
         if (empty($handler)) {
125 125
             throw new InvalidArgumentException('La configuration du cache doit avoir un ensemble de gestionnaires.');
126 126
         }
127 127
 
128
-        if (! array_key_exists($handler, $validHandlers)) {
128
+        if (!array_key_exists($handler, $validHandlers)) {
129 129
             throw new InvalidArgumentException('La configuration du cache a un gestionnaire non valide spécifié.');
130 130
         }
131 131
 
132
-        $adapter = new $validHandlers[$handler]();
133
-        if (! ($adapter instanceof BaseHandler)) {
132
+        $adapter = new $validHandlers[ $handler ]();
133
+        if (!($adapter instanceof BaseHandler)) {
134 134
             if (empty($fallback)) {
135 135
                 $adapter = new Dummy();
136
-            } elseif (! array_key_exists($fallback, $validHandlers)) {
136
+            } elseif (!array_key_exists($fallback, $validHandlers)) {
137 137
                 throw new InvalidArgumentException('La configuration du cache a un gestionnaire de secours non valide spécifié.');
138 138
             } else {
139
-                $adapter = new $validHandlers[$fallback]();
139
+                $adapter = new $validHandlers[ $fallback ]();
140 140
             }
141 141
         }
142 142
 
143
-        if (! ($adapter instanceof BaseHandler)) {
143
+        if (!($adapter instanceof BaseHandler)) {
144 144
             throw new InvalidArgumentException('Le gestionnaire de cache doit utiliser BlitzPHP\Cache\Handlers\BaseHandler comme classe de base.');
145 145
         }
146 146
 
147
-        if (isset($this->config[$handler]) && is_array($this->config[$handler])) {
148
-            $this->config = array_merge($this->config, $this->config[$handler]);
149
-            unset($this->config[$handler]);
147
+        if (isset($this->config[ $handler ]) && is_array($this->config[ $handler ])) {
148
+            $this->config = array_merge($this->config, $this->config[ $handler ]);
149
+            unset($this->config[ $handler ]);
150 150
         }
151 151
 
152
-        if (! $adapter->init($this->config)) {
152
+        if (!$adapter->init($this->config)) {
153 153
             throw new RuntimeException(
154 154
                 sprintf(
155 155
                     'Le moteur de cache %s n\'est pas correctement configuré. Consultez le journal des erreurs pour plus d\'informations.',
@@ -179,7 +179,7 @@  discard block
 block discarded – undo
179 179
      *
180 180
      * @return bool Vrai si les données ont été mises en cache avec succès, faux en cas d'échec
181 181
      */
182
-    public function write(string $key, mixed $value, null|DateInterval|int $ttl = null): bool
182
+    public function write(string $key, mixed $value, null | DateInterval | int $ttl = null): bool
183 183
     {
184 184
         if (is_resource($value)) {
185 185
             return false;
@@ -204,7 +204,7 @@  discard block
 block discarded – undo
204 204
     /**
205 205
      * {@inheritDoc}
206 206
      */
207
-    public function set(string $key, mixed $value, null|DateInterval|int $ttl = null): bool
207
+    public function set(string $key, mixed $value, null | DateInterval | int $ttl = null): bool
208 208
     {
209 209
         return $this->write($key, $value, $ttl);
210 210
     }
@@ -229,7 +229,7 @@  discard block
 block discarded – undo
229 229
      *
230 230
      * @throws InvalidArgumentException
231 231
      */
232
-    public function writeMany(iterable $data, null|DateInterval|int $ttl = null): bool
232
+    public function writeMany(iterable $data, null | DateInterval | int $ttl = null): bool
233 233
     {
234 234
         return $this->factory()->setMultiple($data, $ttl);
235 235
     }
@@ -237,7 +237,7 @@  discard block
 block discarded – undo
237 237
     /**
238 238
      * {@inheritDoc}
239 239
      */
240
-    public function setMultiple(iterable $values, null|DateInterval|int $ttl = null): bool
240
+    public function setMultiple(iterable $values, null | DateInterval | int $ttl = null): bool
241 241
     {
242 242
         return $this->writeMany($values, $ttl);
243 243
     }
@@ -487,7 +487,7 @@  discard block
 block discarded – undo
487 487
      * @return mixed Si la clé est trouvée : les données en cache.
488 488
      *               Si la clé n'est pas trouvée, la valeur renvoyée par le callable.
489 489
      */
490
-    public function remember(string $key, callable|DateInterval|int|null $ttl, callable $callable): mixed
490
+    public function remember(string $key, callable | DateInterval | int | null $ttl, callable $callable): mixed
491 491
     {
492 492
         return $this->factory()->remember($key, $callable, $ttl);
493 493
     }
@@ -539,7 +539,7 @@  discard block
 block discarded – undo
539 539
      */
540 540
     public function pull(string $key, $default = null)
541 541
     {
542
-        return Helpers::tap($this->read($key, $default), function () use ($key) {
542
+        return Helpers::tap($this->read($key, $default), function() use ($key) {
543 543
             $this->delete($key);
544 544
         });
545 545
     }
@@ -554,7 +554,7 @@  discard block
 block discarded – undo
554 554
      */
555 555
     public function pullMany(iterable $keys, $default = null)
556 556
     {
557
-        return Helpers::tap($this->readMany($keys, $default), function () use ($keys) {
557
+        return Helpers::tap($this->readMany($keys, $default), function() use ($keys) {
558 558
             $this->deleteMany($keys);
559 559
         });
560 560
     }
Please login to merge, or discard this patch.