Passed
Push — main ( c607be...523453 )
by Dimitri
11:22
created
Handlers/BaseHandler.php 1 patch
Spacing   +22 added lines, -22 removed lines patch added patch discarded remove patch
@@ -60,7 +60,7 @@  discard block
 block discarded – undo
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,20 +81,20 @@  discard block
 block discarded – undo
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
-        if (isset($config['prefix'])) {
87
-           $config['prefix'] = str_replace(' ', '-', strtolower($config['prefix'])); 
86
+        if (isset($config[ 'prefix' ])) {
87
+           $config[ 'prefix' ] = str_replace(' ', '-', strtolower($config[ 'prefix' ])); 
88 88
         }
89 89
 
90 90
         $this->setConfig($config);
91 91
 
92
-        if (! empty($this->_config['groups'])) {
93
-            sort($this->_config['groups']);
94
-            $this->_groupPrefix = str_repeat('%s_', count($this->_config['groups']));
92
+        if (!empty($this->_config[ 'groups' ])) {
93
+            sort($this->_config[ 'groups' ]);
94
+            $this->_groupPrefix = str_repeat('%s_', count($this->_config[ 'groups' ]));
95 95
         }
96
-        if (! is_numeric($this->_config['duration'])) {
97
-            $this->_config['duration'] = strtotime($this->_config['duration']) - time();
96
+        if (!is_numeric($this->_config[ 'duration' ])) {
97
+            $this->_config[ 'duration' ] = strtotime($this->_config[ 'duration' ]) - time();
98 98
         }
99 99
 
100 100
         return true;
@@ -115,13 +115,13 @@  discard block
 block discarded – undo
115 115
      */
116 116
     public function ensureValidKey(string $key): void
117 117
     {
118
-        if (! is_string($key) || $key === '') {
118
+        if (!is_string($key) || $key === '') {
119 119
             throw new InvalidArgumentException('Une clé de cache doit être une chaîne non vide.');
120 120
         }
121 121
 
122 122
         $reserved = self::$reservedCharacters;
123 123
         if ($reserved && strpbrk($key, $reserved) !== false) {
124
-            throw new InvalidArgumentException('La clé de cache contient des caractères réservés ' . $reserved);
124
+            throw new InvalidArgumentException('La clé de cache contient des caractères réservés '.$reserved);
125 125
         }
126 126
     }
127 127
 
@@ -135,7 +135,7 @@  discard block
 block discarded – undo
135 135
      */
136 136
     protected function ensureValidType($iterable, string $check = self::CHECK_VALUE): void
137 137
     {
138
-        if (! is_iterable($iterable)) {
138
+        if (!is_iterable($iterable)) {
139 139
             throw new InvalidArgumentException(sprintf(
140 140
                 'Un cache %s doit être soit un tableau soit un Traversable.',
141 141
                 $check === self::CHECK_VALUE ? 'key set' : 'set'
@@ -179,7 +179,7 @@  discard block
 block discarded – undo
179 179
      * @return mixed Si la clé est trouvée : les données en cache.
180 180
      *               Si la clé n'est pas trouvée, la valeur renvoyée par le callable.
181 181
      */
182
-    public function remember(string $key, callable|DateInterval|int|null $ttl, callable $callable = null): mixed
182
+    public function remember(string $key, callable | DateInterval | int | null $ttl, callable $callable = null): mixed
183 183
     {
184 184
         if (is_callable($ttl)) {
185 185
             $callable = $ttl;
@@ -222,10 +222,10 @@  discard block
 block discarded – undo
222 222
     {
223 223
         $this->ensureValidType($keys);
224 224
 
225
-        $results = [];
225
+        $results = [ ];
226 226
 
227 227
         foreach ($keys as $key) {
228
-            $results[$key] = $this->get($key, $default);
228
+            $results[ $key ] = $this->get($key, $default);
229 229
         }
230 230
 
231 231
         return $results;
@@ -244,7 +244,7 @@  discard block
 block discarded – undo
244 244
      * @throws InvalidArgumentException Si $values n'est ni un tableau ni un Traversable,
245 245
      *                                  ou si l'une des valeurs $ n'est pas une valeur légale.
246 246
      */
247
-    public function setMultiple(iterable $values, null|DateInterval|int $ttl = null): bool
247
+    public function setMultiple(iterable $values, null | DateInterval | int $ttl = null): bool
248 248
     {
249 249
         $this->ensureValidType($values, self::CHECK_KEY);
250 250
 
@@ -290,7 +290,7 @@  discard block
 block discarded – undo
290 290
         $result = true;
291 291
 
292 292
         foreach ($keys as $key) {
293
-            if (! $this->delete($key)) {
293
+            if (!$this->delete($key)) {
294 294
                 $result = false;
295 295
             }
296 296
         }
@@ -329,7 +329,7 @@  discard block
 block discarded – undo
329 329
      *
330 330
      * @return bool Vrai en cas de succès et faux en cas d'échec.
331 331
      */
332
-    abstract public function set(string $key, mixed $value, null|DateInterval|int $ttl = null): bool;
332
+    abstract public function set(string $key, mixed $value, null | DateInterval | int $ttl = null): bool;
333 333
 
334 334
     /**
335 335
      * {@inheritDoc}
@@ -386,7 +386,7 @@  discard block
 block discarded – undo
386 386
      */
387 387
     public function groups(): array
388 388
     {
389
-        return $this->_config['groups'];
389
+        return $this->_config[ 'groups' ];
390 390
     }
391 391
 
392 392
     /**
@@ -411,7 +411,7 @@  discard block
 block discarded – undo
411 411
         }
412 412
         $key = preg_replace('/[\s]+/', '_', $key);
413 413
 
414
-        return $this->_config['prefix'] . $prefix . $key;
414
+        return $this->_config[ 'prefix' ].$prefix.$key;
415 415
     }
416 416
 
417 417
     /**
@@ -433,10 +433,10 @@  discard block
 block discarded – undo
433 433
      * @param DateInterval|int|null $ttl La valeur TTL de cet élément. Si null est envoyé,
434 434
      *                                   La durée par défaut du conducteur sera utilisée.
435 435
      */
436
-    protected function duration(null|DateInterval|int $ttl): int
436
+    protected function duration(null | DateInterval | int $ttl): int
437 437
     {
438 438
         if ($ttl === null) {
439
-            return $this->_config['duration'];
439
+            return $this->_config[ 'duration' ];
440 440
         }
441 441
 
442 442
         if (is_int($ttl)) {
Please login to merge, or discard this patch.