Passed
Push — main ( 7c2b5d...a879dc )
by Dimitri
02:51
created
Cache.php 1 patch
Spacing   +25 added lines, -25 removed lines patch added patch discarded remove patch
@@ -74,7 +74,7 @@  discard block
 block discarded – undo
74 74
     /**
75 75
      * Configuration des caches
76 76
      */
77
-    protected array $config = [];
77
+    protected array $config = [ ];
78 78
 
79 79
     /**
80 80
      * Adapter a utiliser pour la mise en cache
@@ -84,7 +84,7 @@  discard block
 block discarded – undo
84 84
     /**
85 85
      * Constructeur
86 86
      */
87
-    public function __construct(array $config = [])
87
+    public function __construct(array $config = [ ])
88 88
     {
89 89
         $this->setConfig($config);
90 90
     }
@@ -107,51 +107,51 @@  discard block
 block discarded – undo
107 107
      */
108 108
     protected function factory(): CacheInterface
109 109
     {
110
-        if (! static::$_enabled) {
110
+        if (!static::$_enabled) {
111 111
             return new Dummy();
112 112
         }
113
-        if (! empty($this->adapter)) {
113
+        if (!empty($this->adapter)) {
114 114
             return $this->adapter;
115 115
         }
116 116
 
117
-        $validHandlers = $this->config['valid_handlers'] ?? self::$validHandlers;
117
+        $validHandlers = $this->config[ 'valid_handlers' ] ?? self::$validHandlers;
118 118
 
119
-        if (empty($validHandlers) || ! is_array($validHandlers)) {
119
+        if (empty($validHandlers) || !is_array($validHandlers)) {
120 120
             throw new InvalidArgumentException('La configuration du cache doit avoir un tableau de $valid_handlers.');
121 121
         }
122 122
 
123
-        $handler  = $this->config['handler'] ?? null;
124
-        $fallback = $this->config['fallback_handler'] ?? null;
123
+        $handler  = $this->config[ 'handler' ] ?? null;
124
+        $fallback = $this->config[ 'fallback_handler' ] ?? null;
125 125
 
126 126
         if (empty($handler)) {
127 127
             throw new InvalidArgumentException('La configuration du cache doit avoir un ensemble de gestionnaires.');
128 128
         }
129 129
 
130
-        if (! array_key_exists($handler, $validHandlers)) {
130
+        if (!array_key_exists($handler, $validHandlers)) {
131 131
             throw new InvalidArgumentException('La configuration du cache a un gestionnaire non valide spécifié.');
132 132
         }
133 133
 
134
-        $adapter = new $validHandlers[$handler]();
135
-        if (! ($adapter instanceof BaseHandler)) {
134
+        $adapter = new $validHandlers[ $handler ]();
135
+        if (!($adapter instanceof BaseHandler)) {
136 136
             if (empty($fallback)) {
137 137
                 $adapter = new Dummy();
138
-            } elseif (! array_key_exists($fallback, $validHandlers)) {
138
+            } elseif (!array_key_exists($fallback, $validHandlers)) {
139 139
                 throw new InvalidArgumentException('La configuration du cache a un gestionnaire de secours non valide spécifié.');
140 140
             } else {
141
-                $adapter = new $validHandlers[$fallback]();
141
+                $adapter = new $validHandlers[ $fallback ]();
142 142
             }
143 143
         }
144 144
 
145
-        if (! ($adapter instanceof BaseHandler)) {
145
+        if (!($adapter instanceof BaseHandler)) {
146 146
             throw new InvalidArgumentException('Le gestionnaire de cache doit utiliser BlitzPHP\Cache\Handlers\BaseHandler comme classe de base.');
147 147
         }
148 148
 
149
-        if (isset($this->config[$handler]) && is_array($this->config[$handler])) {
150
-            $this->config = array_merge($this->config, $this->config[$handler]);
151
-            unset($this->config[$handler]);
149
+        if (isset($this->config[ $handler ]) && is_array($this->config[ $handler ])) {
150
+            $this->config = array_merge($this->config, $this->config[ $handler ]);
151
+            unset($this->config[ $handler ]);
152 152
         }
153 153
 
154
-        if (! $adapter->init($this->config)) {
154
+        if (!$adapter->init($this->config)) {
155 155
             throw new RuntimeException(
156 156
                 sprintf(
157 157
                     'Le moteur de cache %s n\'est pas correctement configuré. Consultez le journal des erreurs pour plus d\'informations.',
@@ -181,7 +181,7 @@  discard block
 block discarded – undo
181 181
      *
182 182
      * @return bool Vrai si les données ont été mises en cache avec succès, faux en cas d'échec
183 183
      */
184
-    public function write(string $key, mixed $value, DateInterval|int|null $ttl = null): bool
184
+    public function write(string $key, mixed $value, DateInterval | int | null $ttl = null): bool
185 185
     {
186 186
         if (is_resource($value)) {
187 187
             return false;
@@ -206,7 +206,7 @@  discard block
 block discarded – undo
206 206
     /**
207 207
      * {@inheritDoc}
208 208
      */
209
-    public function set(string $key, mixed $value, DateInterval|int|null $ttl = null): bool
209
+    public function set(string $key, mixed $value, DateInterval | int | null $ttl = null): bool
210 210
     {
211 211
         return $this->write($key, $value, $ttl);
212 212
     }
@@ -231,7 +231,7 @@  discard block
 block discarded – undo
231 231
      *
232 232
      * @throws InvalidArgumentException
233 233
      */
234
-    public function writeMany(iterable $data, DateInterval|int|null $ttl = null): bool
234
+    public function writeMany(iterable $data, DateInterval | int | null $ttl = null): bool
235 235
     {
236 236
         return $this->factory()->setMultiple($data, $ttl);
237 237
     }
@@ -239,7 +239,7 @@  discard block
 block discarded – undo
239 239
     /**
240 240
      * {@inheritDoc}
241 241
      */
242
-    public function setMultiple(iterable $values, DateInterval|int|null $ttl = null): bool
242
+    public function setMultiple(iterable $values, DateInterval | int | null $ttl = null): bool
243 243
     {
244 244
         return $this->writeMany($values, $ttl);
245 245
     }
@@ -488,7 +488,7 @@  discard block
 block discarded – undo
488 488
      * @return mixed Si la clé est trouvée : les données en cache.
489 489
      *               Si la clé n'est pas trouvée, la valeur renvoyée par le callable.
490 490
      */
491
-    public function remember(string $key, callable|DateInterval|int|null $ttl, ?callable $callable = null): mixed
491
+    public function remember(string $key, callable | DateInterval | int | null $ttl, ?callable $callable = null): mixed
492 492
     {
493 493
         return $this->factory()->remember($key, $ttl, $callable);
494 494
     }
@@ -541,7 +541,7 @@  discard block
 block discarded – undo
541 541
      */
542 542
     public function pull(string $key, $default = null)
543 543
     {
544
-        return Helpers::tap($this->read($key, $default), function () use ($key) {
544
+        return Helpers::tap($this->read($key, $default), function() use ($key) {
545 545
             $this->delete($key);
546 546
         });
547 547
     }
@@ -557,7 +557,7 @@  discard block
 block discarded – undo
557 557
      */
558 558
     public function pullMany(iterable $keys, $default = null)
559 559
     {
560
-        return Helpers::tap($this->readMany($keys, $default), function () use ($keys) {
560
+        return Helpers::tap($this->readMany($keys, $default), function() use ($keys) {
561 561
             $this->deleteMany($keys);
562 562
         });
563 563
     }
Please login to merge, or discard this patch.
Handlers/Wincache.php 1 patch
Spacing   +16 added lines, -16 removed lines patch added patch discarded remove patch
@@ -25,14 +25,14 @@  discard block
 block discarded – undo
25 25
      * Contient les noms de groupe compilés
26 26
      * (préfixé par le préfixe de configuration global)
27 27
      */
28
-    protected array $_compiledGroupNames = [];
28
+    protected array $_compiledGroupNames = [ ];
29 29
 
30 30
     /**
31 31
      * {@inheritDoc}
32 32
      */
33
-    public function init(array $config = []): bool
33
+    public function init(array $config = [ ]): bool
34 34
     {
35
-        if (! extension_loaded('wincache')) {
35
+        if (!extension_loaded('wincache')) {
36 36
             throw new RuntimeException('L\'extension `wincache` doit être activée pour utiliser WincacheHandler.');
37 37
         }
38 38
 
@@ -44,7 +44,7 @@  discard block
 block discarded – undo
44 44
     /**
45 45
      * {@inheritDoc}
46 46
      */
47
-    public function set(string $key, mixed $value, DateInterval|int|null $ttl = null): bool
47
+    public function set(string $key, mixed $value, DateInterval | int | null $ttl = null): bool
48 48
     {
49 49
         $key      = $this->_key($key);
50 50
         $duration = $this->duration($ttl);
@@ -101,12 +101,12 @@  discard block
 block discarded – undo
101 101
     public function clear(): bool
102 102
     {
103 103
         $info      = wincache_ucache_info();
104
-        $cacheKeys = $info['ucache_entries'];
104
+        $cacheKeys = $info[ 'ucache_entries' ];
105 105
         unset($info);
106 106
 
107 107
         foreach ($cacheKeys as $key) {
108
-            if (str_starts_with($key['key_name'], $this->_config['prefix'])) {
109
-                wincache_ucache_delete($key['key_name']);
108
+            if (str_starts_with($key[ 'key_name' ], $this->_config[ 'prefix' ])) {
109
+                wincache_ucache_delete($key[ 'key_name' ]);
110 110
             }
111 111
         }
112 112
 
@@ -127,27 +127,27 @@  discard block
 block discarded – undo
127 127
     public function groups(): array
128 128
     {
129 129
         if (empty($this->_compiledGroupNames)) {
130
-            foreach ($this->_config['groups'] as $group) {
131
-                $this->_compiledGroupNames[] = $this->_config['prefix'] . $group;
130
+            foreach ($this->_config[ 'groups' ] as $group) {
131
+                $this->_compiledGroupNames[ ] = $this->_config[ 'prefix' ].$group;
132 132
             }
133 133
         }
134 134
 
135 135
         $groups = wincache_ucache_get($this->_compiledGroupNames);
136
-        if (count($groups) !== count($this->_config['groups'])) {
136
+        if (count($groups) !== count($this->_config[ 'groups' ])) {
137 137
             foreach ($this->_compiledGroupNames as $group) {
138
-                if (! isset($groups[$group])) {
138
+                if (!isset($groups[ $group ])) {
139 139
                     wincache_ucache_set($group, 1);
140
-                    $groups[$group] = 1;
140
+                    $groups[ $group ] = 1;
141 141
                 }
142 142
             }
143 143
             ksort($groups);
144 144
         }
145 145
 
146
-        $result = [];
146
+        $result = [ ];
147 147
         $groups = array_values($groups);
148 148
 
149
-        foreach ($this->_config['groups'] as $i => $group) {
150
-            $result[] = $group . $groups[$i];
149
+        foreach ($this->_config[ 'groups' ] as $i => $group) {
150
+            $result[ ] = $group.$groups[ $i ];
151 151
         }
152 152
 
153 153
         return $result;
@@ -159,7 +159,7 @@  discard block
 block discarded – undo
159 159
     public function clearGroup(string $group): bool
160 160
     {
161 161
         $success = false;
162
-        wincache_ucache_inc($this->_config['prefix'] . $group, 1, $success);
162
+        wincache_ucache_inc($this->_config[ 'prefix' ].$group, 1, $success);
163 163
 
164 164
         return $success;
165 165
     }
Please login to merge, or discard this patch.
Handlers/FileVarExportHandler.php 1 patch
Spacing   +13 added lines, -13 removed lines patch added patch discarded remove patch
@@ -26,12 +26,12 @@  discard block
 block discarded – undo
26 26
     public function __construct(?string $path = null)
27 27
     {
28 28
         if (null === $path) {
29
-            $path = sys_get_temp_dir() . DIRECTORY_SEPARATOR . 'blitz-php' . DIRECTORY_SEPARATOR . 'cache';
29
+            $path = sys_get_temp_dir().DIRECTORY_SEPARATOR.'blitz-php'.DIRECTORY_SEPARATOR.'cache';
30 30
         }
31 31
 
32 32
         $this->path = rtrim($path, '/\\');
33 33
 
34
-        if (! is_dir($this->path)) {
34
+        if (!is_dir($this->path)) {
35 35
             mkdir($this->path, 0777, true);
36 36
         }
37 37
     }
@@ -47,7 +47,7 @@  discard block
 block discarded – undo
47 47
     /**
48 48
      * {@inheritDoc}
49 49
      */
50
-    public function init(array $config = []): bool
50
+    public function init(array $config = [ ]): bool
51 51
     {
52 52
         return true;
53 53
     }
@@ -57,21 +57,21 @@  discard block
 block discarded – undo
57 57
      *
58 58
      * @param array|bool|float|int|object|string|null $value
59 59
      */
60
-    public function set(string $key, mixed $value, DateInterval|int|null $ttl = null): bool
60
+    public function set(string $key, mixed $value, DateInterval | int | null $ttl = null): bool
61 61
     {
62 62
         $value = var_export($value, true);
63 63
 
64 64
         // Écrire d'abord dans le fichier temporaire pour assurer l'atomicité
65
-        $tmp = $this->path . "/{$key}." . uniqid('', true) . '.tmp';
66
-        file_put_contents($tmp, '<?php return ' . $value . ';', LOCK_EX);
65
+        $tmp = $this->path."/{$key}.".uniqid('', true).'.tmp';
66
+        file_put_contents($tmp, '<?php return '.$value.';', LOCK_EX);
67 67
 
68
-        return rename($tmp, $this->path . "/{$key}");
68
+        return rename($tmp, $this->path."/{$key}");
69 69
     }
70 70
 
71 71
     /**
72 72
      * {@inheritDoc}
73 73
      */
74
-    public function setMultiple(iterable $values, DateInterval|int|null $ttl = null): bool
74
+    public function setMultiple(iterable $values, DateInterval | int | null $ttl = null): bool
75 75
     {
76 76
         return true;
77 77
     }
@@ -83,7 +83,7 @@  discard block
 block discarded – undo
83 83
      */
84 84
     public function get(string $key, mixed $default = null): mixed
85 85
     {
86
-        return @include $this->path . "/{$key}";
86
+        return @include $this->path."/{$key}";
87 87
     }
88 88
 
89 89
     /**
@@ -91,7 +91,7 @@  discard block
 block discarded – undo
91 91
      */
92 92
     public function getMultiple(iterable $keys, mixed $default = null): iterable
93 93
     {
94
-        return [];
94
+        return [ ];
95 95
     }
96 96
 
97 97
     /**
@@ -115,7 +115,7 @@  discard block
 block discarded – undo
115 115
      */
116 116
     public function delete(string $key): bool
117 117
     {
118
-        return @unlink($this->path . "/{$key}");
118
+        return @unlink($this->path."/{$key}");
119 119
     }
120 120
 
121 121
     /**
@@ -131,11 +131,11 @@  discard block
 block discarded – undo
131 131
      */
132 132
     public function clear(): bool
133 133
     {
134
-        if (! is_dir($this->path)) {
134
+        if (!is_dir($this->path)) {
135 135
             return false;
136 136
         }
137 137
 
138
-        $files = glob($this->path . '/*');
138
+        $files = glob($this->path.'/*');
139 139
 
140 140
         foreach ($files as $file) {
141 141
             if (is_file($file)) {
Please login to merge, or discard this patch.
Handlers/Apcu.php 1 patch
Spacing   +19 added lines, -19 removed lines patch added patch discarded remove patch
@@ -26,14 +26,14 @@  discard block
 block discarded – undo
26 26
      *
27 27
      * @var list<string>
28 28
      */
29
-    protected array $_compiledGroupNames = [];
29
+    protected array $_compiledGroupNames = [ ];
30 30
 
31 31
     /**
32 32
      * {@inheritDoc}
33 33
      */
34
-    public function init(array $config = []): bool
34
+    public function init(array $config = [ ]): bool
35 35
     {
36
-        if (! extension_loaded('apcu')) {
36
+        if (!extension_loaded('apcu')) {
37 37
             throw new RuntimeException('L\'extension `apcu` doit être activée pour utiliser ApcuHandler.');
38 38
         }
39 39
 
@@ -43,7 +43,7 @@  discard block
 block discarded – undo
43 43
     /**
44 44
      * {@inheritDoc}
45 45
      */
46
-    public function set(string $key, mixed $value, DateInterval|int|null $ttl = null): bool
46
+    public function set(string $key, mixed $value, DateInterval | int | null $ttl = null): bool
47 47
     {
48 48
         $key      = $this->_key($key);
49 49
         $duration = $this->duration($ttl);
@@ -112,7 +112,7 @@  discard block
 block discarded – undo
112 112
     {
113 113
         if (class_exists(APCUIterator::class, false)) {
114 114
             $iterator = new APCUIterator(
115
-                '/^' . preg_quote($this->_config['prefix'], '/') . '/',
115
+                '/^'.preg_quote($this->_config[ 'prefix' ], '/').'/',
116 116
                 APC_ITER_NONE
117 117
             );
118 118
             apcu_delete($iterator);
@@ -122,9 +122,9 @@  discard block
 block discarded – undo
122 122
 
123 123
         $cache = apcu_cache_info(); // Déclenche déjà un avertissement par lui-même
124 124
 
125
-        foreach ($cache['cache_list'] as $key) {
126
-            if (str_starts_with($key['info'], $this->_config['prefix'])) {
127
-                apcu_delete($key['info']);
125
+        foreach ($cache[ 'cache_list' ] as $key) {
126
+            if (str_starts_with($key[ 'info' ], $this->_config[ 'prefix' ])) {
127
+                apcu_delete($key[ 'info' ]);
128 128
             }
129 129
         }
130 130
 
@@ -139,7 +139,7 @@  discard block
 block discarded – undo
139 139
     public function add(string $key, mixed $value): bool
140 140
     {
141 141
         $key      = $this->_key($key);
142
-        $duration = $this->_config['duration'];
142
+        $duration = $this->_config[ 'duration' ];
143 143
 
144 144
         return apcu_add($key, $value, $duration);
145 145
     }
@@ -152,34 +152,34 @@  discard block
 block discarded – undo
152 152
      */
153 153
     public function groups(): array
154 154
     {
155
-        if ($this->_compiledGroupNames === []) {
156
-            foreach ($this->_config['groups'] as $group) {
157
-                $this->_compiledGroupNames[] = $this->_config['prefix'] . $group;
155
+        if ($this->_compiledGroupNames === [ ]) {
156
+            foreach ($this->_config[ 'groups' ] as $group) {
157
+                $this->_compiledGroupNames[ ] = $this->_config[ 'prefix' ].$group;
158 158
             }
159 159
         }
160 160
 
161 161
         $success = false;
162 162
         $groups  = apcu_fetch($this->_compiledGroupNames, $success);
163
-        if ($success && count($groups) !== count($this->_config['groups'])) {
163
+        if ($success && count($groups) !== count($this->_config[ 'groups' ])) {
164 164
             foreach ($this->_compiledGroupNames as $group) {
165
-                if (! isset($groups[$group])) {
165
+                if (!isset($groups[ $group ])) {
166 166
                     $value = 1;
167 167
                     if (apcu_store($group, $value) === false) {
168 168
                         $this->warning(
169 169
                             sprintf('Impossible de stocker la clé "%s" avec la valeur "%s" dans le cache APCu.', $group, $value)
170 170
                         );
171 171
                     }
172
-                    $groups[$group] = $value;
172
+                    $groups[ $group ] = $value;
173 173
                 }
174 174
             }
175 175
             ksort($groups);
176 176
         }
177 177
 
178
-        $result = [];
178
+        $result = [ ];
179 179
         $groups = array_values($groups);
180 180
 
181
-        foreach ($this->_config['groups'] as $i => $group) {
182
-            $result[] = $group . $groups[$i];
181
+        foreach ($this->_config[ 'groups' ] as $i => $group) {
182
+            $result[ ] = $group.$groups[ $i ];
183 183
         }
184 184
 
185 185
         return $result;
@@ -193,7 +193,7 @@  discard block
 block discarded – undo
193 193
     public function clearGroup(string $group): bool
194 194
     {
195 195
         $success = false;
196
-        apcu_inc($this->_config['prefix'] . $group, 1, $success);
196
+        apcu_inc($this->_config[ 'prefix' ].$group, 1, $success);
197 197
 
198 198
         return $success;
199 199
     }
Please login to merge, or discard this patch.
Handlers/File.php 2 patches
Indentation   +9 added lines, -9 removed lines patch added patch discarded remove patch
@@ -47,14 +47,14 @@  discard block
 block discarded – undo
47 47
      * @var array<string, mixed>
48 48
      */
49 49
     protected array $_defaultConfig = [
50
-		'duration'  => 3600,
51
-		'groups'    => [],
52
-		'lock'      => true,
53
-		'mask'      => 0o664,
54
-		'dirMask'   => 0770,
55
-		'path'      => null,
56
-		'prefix'    => 'blitz_',
57
-		'serialize' => true,
50
+  'duration'  => 3600,
51
+  'groups'    => [],
52
+  'lock'      => true,
53
+  'mask'      => 0o664,
54
+  'dirMask'   => 0770,
55
+  'path'      => null,
56
+  'prefix'    => 'blitz_',
57
+  'serialize' => true,
58 58
     ];
59 59
 
60 60
     /**
@@ -438,7 +438,7 @@  discard block
 block discarded – undo
438 438
         );
439 439
 
440 440
         foreach ($filtered as $object) {
441
-			/** @var \SplFileInfo $object */
441
+   /** @var \SplFileInfo $object */
442 442
             $path = $object->getPathname();
443 443
             unset($object);
444 444
             // phpcs:ignore
Please login to merge, or discard this patch.
Spacing   +68 added lines, -68 removed lines patch added patch discarded remove patch
@@ -48,7 +48,7 @@  discard block
 block discarded – undo
48 48
      */
49 49
     protected array $_defaultConfig = [
50 50
 		'duration'  => 3600,
51
-		'groups'    => [],
51
+		'groups'    => [ ],
52 52
 		'lock'      => true,
53 53
 		'mask'      => 0o664,
54 54
 		'dirMask'   => 0770,
@@ -65,15 +65,15 @@  discard block
 block discarded – undo
65 65
     /**
66 66
      * {@inheritDoc}
67 67
      */
68
-    public function init(array $config = []): bool
68
+    public function init(array $config = [ ]): bool
69 69
     {
70 70
         parent::init($config);
71 71
 
72
-        if ($this->_config['path'] === null) {
73
-            $this->_config['path'] = sys_get_temp_dir() . DIRECTORY_SEPARATOR . 'blitz-php' . DIRECTORY_SEPARATOR . 'cache' . DIRECTORY_SEPARATOR;
72
+        if ($this->_config[ 'path' ] === null) {
73
+            $this->_config[ 'path' ] = sys_get_temp_dir().DIRECTORY_SEPARATOR.'blitz-php'.DIRECTORY_SEPARATOR.'cache'.DIRECTORY_SEPARATOR;
74 74
         }
75
-        if (substr($this->_config['path'], -1) !== DIRECTORY_SEPARATOR) {
76
-            $this->_config['path'] .= DIRECTORY_SEPARATOR;
75
+        if (substr($this->_config[ 'path' ], -1) !== DIRECTORY_SEPARATOR) {
76
+            $this->_config[ 'path' ] .= DIRECTORY_SEPARATOR;
77 77
         }
78 78
         if ($this->_groupPrefix) {
79 79
             $this->_groupPrefix = str_replace('_', DIRECTORY_SEPARATOR, $this->_groupPrefix);
@@ -85,9 +85,9 @@  discard block
 block discarded – undo
85 85
     /**
86 86
      * {@inheritDoc}
87 87
      */
88
-    public function set(string $key, mixed $value, DateInterval|int|null $ttl = null): bool
88
+    public function set(string $key, mixed $value, DateInterval | int | null $ttl = null): bool
89 89
     {
90
-        if ($value === '' || ! $this->_init) {
90
+        if ($value === '' || !$this->_init) {
91 91
             return false;
92 92
         }
93 93
 
@@ -97,14 +97,14 @@  discard block
 block discarded – undo
97 97
             return false;
98 98
         }
99 99
 
100
-        if (! empty($this->_config['serialize'])) {
100
+        if (!empty($this->_config[ 'serialize' ])) {
101 101
             $value = serialize($value);
102 102
         }
103 103
 
104 104
         $expires  = time() + $this->duration($ttl);
105
-        $contents = implode('', [$expires, PHP_EOL, $value, PHP_EOL]);
105
+        $contents = implode('', [ $expires, PHP_EOL, $value, PHP_EOL ]);
106 106
 
107
-        if ($this->_config['lock']) {
107
+        if ($this->_config[ 'lock' ]) {
108 108
             $this->_File->flock(LOCK_EX);
109 109
         }
110 110
 
@@ -113,7 +113,7 @@  discard block
 block discarded – undo
113 113
             && $this->_File->fwrite($contents)
114 114
             && $this->_File->fflush();
115 115
 
116
-        if ($this->_config['lock']) {
116
+        if ($this->_config[ 'lock' ]) {
117 117
             $this->_File->flock(LOCK_UN);
118 118
         }
119 119
         unset($this->_File);
@@ -128,11 +128,11 @@  discard block
 block discarded – undo
128 128
     {
129 129
         $key = $this->_key($key);
130 130
 
131
-        if (! $this->_init || $this->_setKey($key) === false) {
131
+        if (!$this->_init || $this->_setKey($key) === false) {
132 132
             return $default;
133 133
         }
134 134
 
135
-        if ($this->_config['lock']) {
135
+        if ($this->_config[ 'lock' ]) {
136 136
             $this->_File->flock(LOCK_SH);
137 137
         }
138 138
 
@@ -141,7 +141,7 @@  discard block
 block discarded – undo
141 141
         $cachetime = (int) $this->_File->current();
142 142
 
143 143
         if ($cachetime < $time) {
144
-            if ($this->_config['lock']) {
144
+            if ($this->_config[ 'lock' ]) {
145 145
                 $this->_File->flock(LOCK_UN);
146 146
             }
147 147
 
@@ -156,13 +156,13 @@  discard block
 block discarded – undo
156 156
             $this->_File->next();
157 157
         }
158 158
 
159
-        if ($this->_config['lock']) {
159
+        if ($this->_config[ 'lock' ]) {
160 160
             $this->_File->flock(LOCK_UN);
161 161
         }
162 162
 
163 163
         $data = trim($data);
164 164
 
165
-        if ($data !== '' && ! empty($this->_config['serialize'])) {
165
+        if ($data !== '' && !empty($this->_config[ 'serialize' ])) {
166 166
             $data = unserialize($data);
167 167
         }
168 168
 
@@ -176,7 +176,7 @@  discard block
 block discarded – undo
176 176
     {
177 177
         $key = $this->_key($key);
178 178
 
179
-        if ($this->_setKey($key) === false || ! $this->_init) {
179
+        if ($this->_setKey($key) === false || !$this->_init) {
180 180
             return false;
181 181
         }
182 182
 
@@ -197,22 +197,22 @@  discard block
 block discarded – undo
197 197
      */
198 198
     public function clear(): bool
199 199
     {
200
-        if (! $this->_init) {
200
+        if (!$this->_init) {
201 201
             return false;
202 202
         }
203 203
         unset($this->_File);
204 204
 
205
-        $this->_clearDirectory($this->_config['path']);
205
+        $this->_clearDirectory($this->_config[ 'path' ]);
206 206
 
207 207
         $directory = new RecursiveDirectoryIterator(
208
-            $this->_config['path'],
208
+            $this->_config[ 'path' ],
209 209
             FilesystemIterator::SKIP_DOTS
210 210
         );
211 211
         $contents = new RecursiveIteratorIterator(
212 212
             $directory,
213 213
             RecursiveIteratorIterator::SELF_FIRST
214 214
         );
215
-        $cleared = [];
215
+        $cleared = [ ];
216 216
 
217 217
         /** @var SplFileInfo $fileInfo */
218 218
         foreach ($contents as $fileInfo) {
@@ -223,16 +223,16 @@  discard block
 block discarded – undo
223 223
             }
224 224
 
225 225
             $realPath = $fileInfo->getRealPath();
226
-            if (! $realPath) {
226
+            if (!$realPath) {
227 227
                 unset($fileInfo);
228 228
 
229 229
                 continue;
230 230
             }
231 231
 
232
-            $path = $realPath . DIRECTORY_SEPARATOR;
233
-            if (! in_array($path, $cleared, true)) {
232
+            $path = $realPath.DIRECTORY_SEPARATOR;
233
+            if (!in_array($path, $cleared, true)) {
234 234
                 $this->_clearDirectory($path);
235
-                $cleared[] = $path;
235
+                $cleared[ ] = $path;
236 236
             }
237 237
 
238 238
             // les itérateurs internes possibles doivent également être désactivés pour que les verrous sur les parents soient libérés
@@ -251,24 +251,24 @@  discard block
 block discarded – undo
251 251
      */
252 252
     protected function _clearDirectory(string $path): void
253 253
     {
254
-        if (! is_dir($path)) {
254
+        if (!is_dir($path)) {
255 255
             return;
256 256
         }
257 257
 
258 258
         $dir = dir($path);
259
-        if (! $dir) {
259
+        if (!$dir) {
260 260
             return;
261 261
         }
262 262
 
263
-        $prefixLength = strlen($this->_config['prefix']);
263
+        $prefixLength = strlen($this->_config[ 'prefix' ]);
264 264
 
265 265
         while (($entry = $dir->read()) !== false) {
266
-            if (substr($entry, 0, $prefixLength) !== $this->_config['prefix']) {
266
+            if (substr($entry, 0, $prefixLength) !== $this->_config[ 'prefix' ]) {
267 267
                 continue;
268 268
             }
269 269
 
270 270
             try {
271
-                $file = new SplFileObject($path . $entry, 'r');
271
+                $file = new SplFileObject($path.$entry, 'r');
272 272
             } catch (Exception $e) {
273 273
                 continue;
274 274
             }
@@ -311,7 +311,7 @@  discard block
 block discarded – undo
311 311
      */
312 312
     public function info()
313 313
     {
314
-        return $this->getDirFileInfo($this->_config['path']);
314
+        return $this->getDirFileInfo($this->_config[ 'path' ]);
315 315
     }
316 316
 
317 317
     /**
@@ -328,15 +328,15 @@  discard block
 block discarded – undo
328 328
         if ($this->_groupPrefix) {
329 329
             $groups = vsprintf($this->_groupPrefix, $this->groups());
330 330
         }
331
-        $dir = $this->_config['path'] . $groups;
331
+        $dir = $this->_config[ 'path' ].$groups;
332 332
 
333
-        if (! is_dir($dir)) {
334
-            mkdir($dir, $this->_config['dirMask'], true);
333
+        if (!is_dir($dir)) {
334
+            mkdir($dir, $this->_config[ 'dirMask' ], true);
335 335
         }
336 336
 
337
-        $path = new SplFileInfo($dir . $key);
337
+        $path = new SplFileInfo($dir.$key);
338 338
 
339
-        if (! $createKey && ! $path->isFile()) {
339
+        if (!$createKey && !$path->isFile()) {
340 340
             return false;
341 341
         }
342 342
         if (
@@ -355,11 +355,11 @@  discard block
 block discarded – undo
355 355
             }
356 356
             unset($path);
357 357
 
358
-            if (! $exists && ! chmod($this->_File->getPathname(), (int) $this->_config['mask'])) {
358
+            if (!$exists && !chmod($this->_File->getPathname(), (int) $this->_config[ 'mask' ])) {
359 359
                 trigger_error(sprintf(
360 360
                     'Impossible d\'appliquer le masque d\'autorisation "%s" sur le fichier cache "%s"',
361 361
                     $this->_File->getPathname(),
362
-                    $this->_config['mask']
362
+                    $this->_config[ 'mask' ]
363 363
                 ), E_USER_WARNING);
364 364
             }
365 365
         }
@@ -372,21 +372,21 @@  discard block
 block discarded – undo
372 372
      */
373 373
     protected function _active(): bool
374 374
     {
375
-        $dir     = new SplFileInfo($this->_config['path']);
375
+        $dir     = new SplFileInfo($this->_config[ 'path' ]);
376 376
         $path    = $dir->getPathname();
377 377
         $success = true;
378
-        if (! is_dir($path)) {
378
+        if (!is_dir($path)) {
379 379
             // phpcs:disable
380
-            $success = @mkdir($path, $this->_config['dirMask'], true);
380
+            $success = @mkdir($path, $this->_config[ 'dirMask' ], true);
381 381
             // phpcs:enable
382 382
         }
383 383
 
384 384
         $isWritableDir = ($dir->isDir() && $dir->isWritable());
385
-        if (! $success || ($this->_init && ! $isWritableDir)) {
385
+        if (!$success || ($this->_init && !$isWritableDir)) {
386 386
             $this->_init = false;
387 387
             trigger_error(sprintf(
388 388
                 '%s n\'est pas ecrivable',
389
-                $this->_config['path']
389
+                $this->_config[ 'path' ]
390 390
             ), E_USER_WARNING);
391 391
         }
392 392
 
@@ -410,17 +410,17 @@  discard block
 block discarded – undo
410 410
     {
411 411
         unset($this->_File);
412 412
 
413
-        $prefix = (string) $this->_config['prefix'];
413
+        $prefix = (string) $this->_config[ 'prefix' ];
414 414
 
415
-        $directoryIterator = new RecursiveDirectoryIterator($this->_config['path']);
415
+        $directoryIterator = new RecursiveDirectoryIterator($this->_config[ 'path' ]);
416 416
         $contents          = new RecursiveIteratorIterator(
417 417
             $directoryIterator,
418 418
             RecursiveIteratorIterator::CHILD_FIRST
419 419
         );
420 420
         $filtered = new CallbackFilterIterator(
421 421
             $contents,
422
-            static function (SplFileInfo $current) use ($group, $prefix) {
423
-                if (! $current->isFile()) {
422
+            static function(SplFileInfo $current) use ($group, $prefix) {
423
+                if (!$current->isFile()) {
424 424
                     return false;
425 425
                 }
426 426
 
@@ -432,7 +432,7 @@  discard block
 block discarded – undo
432 432
 
433 433
                 return str_contains(
434 434
                     $current->getPathname(),
435
-                    DIRECTORY_SEPARATOR . $group . DIRECTORY_SEPARATOR,
435
+                    DIRECTORY_SEPARATOR.$group.DIRECTORY_SEPARATOR,
436 436
                 );
437 437
             }
438 438
         );
@@ -466,23 +466,23 @@  discard block
 block discarded – undo
466 466
      */
467 467
     protected function getDirFileInfo(string $sourceDir, bool $topLevelOnly = true, bool $_recursion = false)
468 468
     {
469
-        static $_filedata = [];
469
+        static $_filedata = [ ];
470 470
         $relativePath     = $sourceDir;
471 471
 
472 472
         if ($fp = @opendir($sourceDir)) {
473 473
             // réinitialise le tableau et s'assure que $source_dir a une barre oblique à la fin de l'appel initial
474 474
             if ($_recursion === false) {
475
-                $_filedata = [];
476
-                $sourceDir = rtrim(realpath($sourceDir) ?: $sourceDir, DIRECTORY_SEPARATOR) . DIRECTORY_SEPARATOR;
475
+                $_filedata = [ ];
476
+                $sourceDir = rtrim(realpath($sourceDir) ?: $sourceDir, DIRECTORY_SEPARATOR).DIRECTORY_SEPARATOR;
477 477
             }
478 478
 
479 479
             // Utilisé pour être foreach (scandir($source_dir, 1) comme $file), mais scandir() n'est tout simplement pas aussi rapide
480 480
             while (false !== ($file = readdir($fp))) {
481
-                if (is_dir($sourceDir . $file) && $file[0] !== '.' && $topLevelOnly === false) {
482
-                    $this->getDirFileInfo($sourceDir . $file . DIRECTORY_SEPARATOR, $topLevelOnly, true);
483
-                } elseif (! is_dir($sourceDir . $file) && $file[0] !== '.') {
484
-                    $_filedata[$file]                  = $this->getFileInfo($sourceDir . $file);
485
-                    $_filedata[$file]['relative_path'] = $relativePath;
481
+                if (is_dir($sourceDir.$file) && $file[ 0 ] !== '.' && $topLevelOnly === false) {
482
+                    $this->getDirFileInfo($sourceDir.$file.DIRECTORY_SEPARATOR, $topLevelOnly, true);
483
+                } elseif (!is_dir($sourceDir.$file) && $file[ 0 ] !== '.') {
484
+                    $_filedata[ $file ]                  = $this->getFileInfo($sourceDir.$file);
485
+                    $_filedata[ $file ][ 'relative_path' ] = $relativePath;
486 486
                 }
487 487
             }
488 488
 
@@ -504,9 +504,9 @@  discard block
 block discarded – undo
504 504
      *
505 505
      * @return array|false
506 506
      */
507
-    protected function getFileInfo(string $file, $returnedValues = ['name', 'server_path', 'size', 'date'])
507
+    protected function getFileInfo(string $file, $returnedValues = [ 'name', 'server_path', 'size', 'date' ])
508 508
     {
509
-        if (! is_file($file)) {
509
+        if (!is_file($file)) {
510 510
             return false;
511 511
         }
512 512
 
@@ -514,40 +514,40 @@  discard block
 block discarded – undo
514 514
             $returnedValues = explode(',', $returnedValues);
515 515
         }
516 516
 
517
-        $fileInfo = [];
517
+        $fileInfo = [ ];
518 518
 
519 519
         foreach ($returnedValues as $key) {
520 520
             switch ($key) {
521 521
                 case 'name':
522
-                    $fileInfo['name'] = basename($file);
522
+                    $fileInfo[ 'name' ] = basename($file);
523 523
                     break;
524 524
 
525 525
                 case 'server_path':
526
-                    $fileInfo['server_path'] = $file;
526
+                    $fileInfo[ 'server_path' ] = $file;
527 527
                     break;
528 528
 
529 529
                 case 'size':
530
-                    $fileInfo['size'] = filesize($file);
530
+                    $fileInfo[ 'size' ] = filesize($file);
531 531
                     break;
532 532
 
533 533
                 case 'date':
534
-                    $fileInfo['date'] = filemtime($file);
534
+                    $fileInfo[ 'date' ] = filemtime($file);
535 535
                     break;
536 536
 
537 537
                 case 'readable':
538
-                    $fileInfo['readable'] = is_readable($file);
538
+                    $fileInfo[ 'readable' ] = is_readable($file);
539 539
                     break;
540 540
 
541 541
                 case 'writable':
542
-                    $fileInfo['writable'] = is_writable($file);
542
+                    $fileInfo[ 'writable' ] = is_writable($file);
543 543
                     break;
544 544
 
545 545
                 case 'executable':
546
-                    $fileInfo['executable'] = is_executable($file);
546
+                    $fileInfo[ 'executable' ] = is_executable($file);
547 547
                     break;
548 548
 
549 549
                 case 'fileperms':
550
-                    $fileInfo['fileperms'] = fileperms($file);
550
+                    $fileInfo[ 'fileperms' ] = fileperms($file);
551 551
                     break;
552 552
             }
553 553
         }
Please login to merge, or discard this patch.
Handlers/BaseHandler.php 2 patches
Indentation   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -240,7 +240,7 @@
 block discarded – undo
240 240
     {
241 241
         $this->ensureValidType($values, self::CHECK_KEY);
242 242
 
243
-		$restore = null;
243
+  $restore = null;
244 244
         if ($ttl !== null) {
245 245
             $restore = $this->getConfig('duration');
246 246
             $this->setConfig('duration', $ttl);
Please login to merge, or discard this patch.
Spacing   +22 added lines, -22 removed lines patch added patch discarded remove patch
@@ -61,7 +61,7 @@  discard block
 block discarded – undo
61 61
      */
62 62
     protected array $_defaultConfig = [
63 63
         'duration'            => 3600,
64
-        'groups'              => [],
64
+        'groups'              => [ ],
65 65
         'prefix'              => 'blitz_',
66 66
         'warnOnWriteFailures' => true,
67 67
     ];
@@ -82,20 +82,20 @@  discard block
 block discarded – undo
82 82
      *
83 83
      * @return bool Vrai si le moteur a été initialisé avec succès, faux sinon
84 84
      */
85
-    public function init(array $config = []): bool
85
+    public function init(array $config = [ ]): bool
86 86
     {
87
-        if (isset($config['prefix'])) {
88
-            $config['prefix'] = str_replace(' ', '-', strtolower($config['prefix']));
87
+        if (isset($config[ 'prefix' ])) {
88
+            $config[ 'prefix' ] = str_replace(' ', '-', strtolower($config[ 'prefix' ]));
89 89
         }
90 90
 
91 91
         $this->setConfig($config);
92 92
 
93
-        if (! empty($this->_config['groups'])) {
94
-            sort($this->_config['groups']);
95
-            $this->_groupPrefix = str_repeat('%s_', count($this->_config['groups']));
93
+        if (!empty($this->_config[ 'groups' ])) {
94
+            sort($this->_config[ 'groups' ]);
95
+            $this->_groupPrefix = str_repeat('%s_', count($this->_config[ 'groups' ]));
96 96
         }
97
-        if (! is_numeric($this->_config['duration'])) {
98
-            $this->_config['duration'] = strtotime($this->_config['duration']) - time();
97
+        if (!is_numeric($this->_config[ 'duration' ])) {
98
+            $this->_config[ 'duration' ] = strtotime($this->_config[ 'duration' ]) - time();
99 99
         }
100 100
 
101 101
         return true;
@@ -116,13 +116,13 @@  discard block
 block discarded – undo
116 116
      */
117 117
     public function ensureValidKey(string $key): void
118 118
     {
119
-        if (! is_string($key) || $key === '') {
119
+        if (!is_string($key) || $key === '') {
120 120
             throw new InvalidArgumentException('Une clé de cache doit être une chaîne non vide.');
121 121
         }
122 122
 
123 123
         $reserved = self::$reservedCharacters;
124 124
         if ($reserved && strpbrk($key, $reserved) !== false) {
125
-            throw new InvalidArgumentException('La clé de cache contient des caractères réservés ' . $reserved);
125
+            throw new InvalidArgumentException('La clé de cache contient des caractères réservés '.$reserved);
126 126
         }
127 127
     }
128 128
 
@@ -171,7 +171,7 @@  discard block
 block discarded – undo
171 171
      * @return mixed Si la clé est trouvée : les données en cache.
172 172
      *               Si la clé n'est pas trouvée, la valeur renvoyée par le callable.
173 173
      */
174
-    public function remember(string $key, callable|DateInterval|int|null $ttl, ?callable $callable = null): mixed
174
+    public function remember(string $key, callable | DateInterval | int | null $ttl, ?callable $callable = null): mixed
175 175
     {
176 176
         if (is_callable($ttl)) {
177 177
             $callable = $ttl;
@@ -214,10 +214,10 @@  discard block
 block discarded – undo
214 214
     {
215 215
         $this->ensureValidType($keys);
216 216
 
217
-        $results = [];
217
+        $results = [ ];
218 218
 
219 219
         foreach ($keys as $key) {
220
-            $results[$key] = $this->get($key, $default);
220
+            $results[ $key ] = $this->get($key, $default);
221 221
         }
222 222
 
223 223
         return $results;
@@ -236,7 +236,7 @@  discard block
 block discarded – undo
236 236
      * @throws InvalidArgumentException Si $values n'est ni un tableau ni un Traversable,
237 237
      *                                  ou si l'une des valeurs $ n'est pas une valeur légale.
238 238
      */
239
-    public function setMultiple(iterable $values, DateInterval|int|null $ttl = null): bool
239
+    public function setMultiple(iterable $values, DateInterval | int | null $ttl = null): bool
240 240
     {
241 241
         $this->ensureValidType($values, self::CHECK_KEY);
242 242
 
@@ -256,7 +256,7 @@  discard block
 block discarded – undo
256 256
 
257 257
             return true;
258 258
         } finally {
259
-            if($restore !== null) {
259
+            if ($restore !== null) {
260 260
                 $this->setConfig('duration', $restore);
261 261
             }
262 262
         }
@@ -283,7 +283,7 @@  discard block
 block discarded – undo
283 283
         $result = true;
284 284
 
285 285
         foreach ($keys as $key) {
286
-            if (! $this->delete($key)) {
286
+            if (!$this->delete($key)) {
287 287
                 $result = false;
288 288
             }
289 289
         }
@@ -322,7 +322,7 @@  discard block
 block discarded – undo
322 322
      *
323 323
      * @return bool Vrai en cas de succès et faux en cas d'échec.
324 324
      */
325
-    abstract public function set(string $key, mixed $value, DateInterval|int|null $ttl = null): bool;
325
+    abstract public function set(string $key, mixed $value, DateInterval | int | null $ttl = null): bool;
326 326
 
327 327
     /**
328 328
      * {@inheritDoc}
@@ -379,7 +379,7 @@  discard block
 block discarded – undo
379 379
      */
380 380
     public function groups(): array
381 381
     {
382
-        return $this->_config['groups'];
382
+        return $this->_config[ 'groups' ];
383 383
     }
384 384
 
385 385
     /**
@@ -404,7 +404,7 @@  discard block
 block discarded – undo
404 404
         }
405 405
         $key = preg_replace('/[\s]+/', '_', $key);
406 406
 
407
-        return $this->_config['prefix'] . $prefix . $key;
407
+        return $this->_config[ 'prefix' ].$prefix.$key;
408 408
     }
409 409
 
410 410
     /**
@@ -426,10 +426,10 @@  discard block
 block discarded – undo
426 426
      * @param DateInterval|int|null $ttl La valeur TTL de cet élément. Si null est envoyé,
427 427
      *                                   La durée par défaut du conducteur sera utilisée.
428 428
      */
429
-    protected function duration(DateInterval|int|null $ttl): int
429
+    protected function duration(DateInterval | int | null $ttl): int
430 430
     {
431 431
         if ($ttl === null) {
432
-            return $this->_config['duration'];
432
+            return $this->_config[ 'duration' ];
433 433
         }
434 434
 
435 435
         if (is_int($ttl)) {
Please login to merge, or discard this patch.
Handlers/RedisHandler.php 2 patches
Indentation   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -272,7 +272,7 @@
 block discarded – undo
272 272
      */
273 273
     public function clear(): bool
274 274
     {
275
-		 if ($this->getConfig('clearUsesFlushDb')) {
275
+   if ($this->getConfig('clearUsesFlushDb')) {
276 276
             $this->_Redis->flushDB(false);
277 277
 
278 278
             return true;
Please login to merge, or discard this patch.
Spacing   +48 added lines, -48 removed lines patch added patch discarded remove patch
@@ -47,7 +47,7 @@  discard block
 block discarded – undo
47 47
     protected array $_defaultConfig = [
48 48
         'database'         => 0,
49 49
         'duration'         => 3600,
50
-        'groups'           => [],
50
+        'groups'           => [ ],
51 51
         'password'         => false,
52 52
         'persistent'       => true,
53 53
         'port'             => 6379,
@@ -63,14 +63,14 @@  discard block
 block discarded – undo
63 63
     /**
64 64
      * {@inheritDoc}
65 65
      */
66
-    public function init(array $config = []): bool
66
+    public function init(array $config = [ ]): bool
67 67
     {
68
-        if (! extension_loaded('redis')) {
68
+        if (!extension_loaded('redis')) {
69 69
             throw new RuntimeException('L\'extension `redis` doit être activée pour utiliser RedisHandler.');
70 70
         }
71 71
 
72
-        if (! empty($config['host'])) {
73
-            $config['server'] = $config['host'];
72
+        if (!empty($config[ 'host' ])) {
73
+            $config[ 'server' ] = $config[ 'host' ];
74 74
         }
75 75
 
76 76
         parent::init($config);
@@ -85,7 +85,7 @@  discard block
 block discarded – undo
85 85
      */
86 86
     protected function _connect(): bool
87 87
     {
88
-        $tls = $this->_config['tls'] === true ? 'tls://' : '';
88
+        $tls = $this->_config[ 'tls' ] === true ? 'tls://' : '';
89 89
 
90 90
         $map = [
91 91
             'ssl_ca'   => 'cafile',
@@ -93,37 +93,37 @@  discard block
 block discarded – undo
93 93
             'ssl_cert' => 'local_cert',
94 94
         ];
95 95
 
96
-        $ssl = [];
96
+        $ssl = [ ];
97 97
         foreach ($map as $key => $context) {
98
-            if (!empty($this->_config[$key])) {
99
-                $ssl[$context] = $this->_config[$key];
98
+            if (!empty($this->_config[ $key ])) {
99
+                $ssl[ $context ] = $this->_config[ $key ];
100 100
             }
101 101
         }
102 102
 
103 103
         try {
104 104
             $this->_Redis = $this->_createRedisInstance();
105
-            if (! empty($this->_config['unix_socket'])) {
106
-                $return = $this->_Redis->connect($this->_config['unix_socket']);
107
-            } elseif (empty($this->_config['persistent'])) {
108
-                $return = $this->_connectTransient($tls . $this->_config['server'], $ssl);
105
+            if (!empty($this->_config[ 'unix_socket' ])) {
106
+                $return = $this->_Redis->connect($this->_config[ 'unix_socket' ]);
107
+            } elseif (empty($this->_config[ 'persistent' ])) {
108
+                $return = $this->_connectTransient($tls.$this->_config[ 'server' ], $ssl);
109 109
             } else {
110
-                $return = $this->_connectPersistent($tls . $this->_config['server'], $ssl);
110
+                $return = $this->_connectPersistent($tls.$this->_config[ 'server' ], $ssl);
111 111
             }
112 112
         } catch (RedisException $e) {
113 113
             if (function_exists('logger')) {
114 114
                 $logger = logger();
115 115
                 if (is_object($logger) && method_exists($logger, 'error')) {
116
-                    $logger->error('RedisEngine n\'a pas pu se connecter. Erreur: ' . $e->getMessage());
116
+                    $logger->error('RedisEngine n\'a pas pu se connecter. Erreur: '.$e->getMessage());
117 117
                 }
118 118
             }
119 119
 
120 120
             return false;
121 121
         }
122
-        if ($return && $this->_config['password']) {
123
-            $return = $this->_Redis->auth($this->_config['password']);
122
+        if ($return && $this->_config[ 'password' ]) {
123
+            $return = $this->_Redis->auth($this->_config[ 'password' ]);
124 124
         }
125 125
         if ($return) {
126
-            return $this->_Redis->select((int) $this->_config['database']);
126
+            return $this->_Redis->select((int) $this->_config[ 'database' ]);
127 127
         }
128 128
 
129 129
         return $return;
@@ -136,22 +136,22 @@  discard block
 block discarded – undo
136 136
      */
137 137
     protected function _connectTransient(string $server, array $ssl): bool
138 138
     {
139
-        if ($ssl === []) {
139
+        if ($ssl === [ ]) {
140 140
             return $this->_Redis->connect(
141 141
                 $server,
142
-                (int) $this->_config['port'],
143
-                (int) $this->_config['timeout'],
142
+                (int) $this->_config[ 'port' ],
143
+                (int) $this->_config[ 'timeout' ],
144 144
             );
145 145
         }
146 146
 
147 147
         return $this->_Redis->connect(
148 148
             $server,
149
-            (int) $this->_config['port'],
150
-            (int) $this->_config['timeout'],
149
+            (int) $this->_config[ 'port' ],
150
+            (int) $this->_config[ 'timeout' ],
151 151
             null,
152 152
             0,
153 153
             0.0,
154
-            ['ssl' => $ssl],
154
+            [ 'ssl' => $ssl ],
155 155
         );
156 156
     }
157 157
 
@@ -162,32 +162,32 @@  discard block
 block discarded – undo
162 162
      */
163 163
     protected function _connectPersistent(string $server, array $ssl): bool
164 164
     {
165
-        $persistentId = $this->_config['port'] . $this->_config['timeout'] . $this->_config['database'];
165
+        $persistentId = $this->_config[ 'port' ].$this->_config[ 'timeout' ].$this->_config[ 'database' ];
166 166
 
167
-        if ($ssl === []) {
167
+        if ($ssl === [ ]) {
168 168
             return $this->_Redis->pconnect(
169 169
                 $server,
170
-                (int) $this->_config['port'],
171
-                (int) $this->_config['timeout'],
170
+                (int) $this->_config[ 'port' ],
171
+                (int) $this->_config[ 'timeout' ],
172 172
                 $persistentId,
173 173
             );
174 174
         }
175 175
 
176 176
         return $this->_Redis->pconnect(
177 177
             $server,
178
-            (int) $this->_config['port'],
179
-            (int) $this->_config['timeout'],
178
+            (int) $this->_config[ 'port' ],
179
+            (int) $this->_config[ 'timeout' ],
180 180
             $persistentId,
181 181
             0,
182 182
             0.0,
183
-            ['ssl' => $ssl],
183
+            [ 'ssl' => $ssl ],
184 184
         );
185 185
     }
186 186
 
187 187
     /**
188 188
      * {@inheritDoc}
189 189
      */
190
-    public function set(string $key, mixed $value, DateInterval|int|null $ttl = null): bool
190
+    public function set(string $key, mixed $value, DateInterval | int | null $ttl = null): bool
191 191
     {
192 192
         $key   = $this->_key($key);
193 193
         $value = $this->serialize($value);
@@ -218,7 +218,7 @@  discard block
 block discarded – undo
218 218
      */
219 219
     public function increment(string $key, int $offset = 1)
220 220
     {
221
-        $duration = $this->_config['duration'];
221
+        $duration = $this->_config[ 'duration' ];
222 222
         $key      = $this->_key($key);
223 223
 
224 224
         $value = $this->_Redis->incrBy($key, $offset);
@@ -234,7 +234,7 @@  discard block
 block discarded – undo
234 234
      */
235 235
     public function decrement(string $key, int $offset = 1)
236 236
     {
237
-        $duration = $this->_config['duration'];
237
+        $duration = $this->_config[ 'duration' ];
238 238
         $key      = $this->_key($key);
239 239
 
240 240
         $value = $this->_Redis->decrBy($key, $offset);
@@ -282,7 +282,7 @@  discard block
 block discarded – undo
282 282
 
283 283
         $isAllDeleted = true;
284 284
         $iterator     = null;
285
-        $pattern      = $this->_config['prefix'] . '*';
285
+        $pattern      = $this->_config[ 'prefix' ].'*';
286 286
 
287 287
         while (true) {
288 288
             $keys = $this->_Redis->scan($iterator, $pattern);
@@ -315,17 +315,17 @@  discard block
 block discarded – undo
315 315
 
316 316
         $isAllDeleted = true;
317 317
         $iterator = null;
318
-        $pattern = $this->_config['prefix'] . '*';
318
+        $pattern = $this->_config[ 'prefix' ].'*';
319 319
 
320 320
         while (true) {
321
-            $keys = $this->_Redis->scan($iterator, $pattern, (int)$this->_config['scanCount']);
321
+            $keys = $this->_Redis->scan($iterator, $pattern, (int) $this->_config[ 'scanCount' ]);
322 322
 
323 323
             if ($keys === false) {
324 324
                 break;
325 325
             }
326 326
 
327 327
             foreach ($keys as $key) {
328
-                $isDeleted = ((int)$this->_Redis->del($key) > 0);
328
+                $isDeleted = ((int) $this->_Redis->del($key) > 0);
329 329
                 $isAllDeleted = $isAllDeleted && $isDeleted;
330 330
             }
331 331
         }
@@ -340,11 +340,11 @@  discard block
 block discarded – undo
340 340
      */
341 341
     public function add(string $key, mixed $value): bool
342 342
     {
343
-        $duration = $this->_config['duration'];
343
+        $duration = $this->_config[ 'duration' ];
344 344
         $key      = $this->_key($key);
345 345
         $value    = $this->serialize($value);
346 346
 
347
-        return (bool) ($this->_Redis->set($key, $value, ['nx', 'ex' => $duration]));
347
+        return (bool) ($this->_Redis->set($key, $value, [ 'nx', 'ex' => $duration ]));
348 348
     }
349 349
 
350 350
     /**
@@ -360,15 +360,15 @@  discard block
 block discarded – undo
360 360
      */
361 361
     public function groups(): array
362 362
     {
363
-        $result = [];
363
+        $result = [ ];
364 364
 
365
-        foreach ($this->_config['groups'] as $group) {
366
-            $value = $this->_Redis->get($this->_config['prefix'] . $group);
367
-            if (! $value) {
365
+        foreach ($this->_config[ 'groups' ] as $group) {
366
+            $value = $this->_Redis->get($this->_config[ 'prefix' ].$group);
367
+            if (!$value) {
368 368
                 $value = $this->serialize(1);
369
-                $this->_Redis->set($this->_config['prefix'] . $group, $value);
369
+                $this->_Redis->set($this->_config[ 'prefix' ].$group, $value);
370 370
             }
371
-            $result[] = $group . $value;
371
+            $result[ ] = $group.$value;
372 372
         }
373 373
 
374 374
         return $result;
@@ -379,7 +379,7 @@  discard block
 block discarded – undo
379 379
      */
380 380
     public function clearGroup(string $group): bool
381 381
     {
382
-        return (bool) $this->_Redis->incr($this->_config['prefix'] . $group);
382
+        return (bool) $this->_Redis->incr($this->_config[ 'prefix' ].$group);
383 383
     }
384 384
 
385 385
     /**
@@ -424,7 +424,7 @@  discard block
 block discarded – undo
424 424
      */
425 425
     public function __destruct()
426 426
     {
427
-        if (empty($this->_config['persistent']) && $this->_Redis instanceof Redis) {
427
+        if (empty($this->_config[ 'persistent' ]) && $this->_Redis instanceof Redis) {
428 428
             $this->_Redis->close();
429 429
         }
430 430
     }
Please login to merge, or discard this patch.
Handlers/Dummy.php 1 patch
Spacing   +5 added lines, -5 removed lines patch added patch discarded remove patch
@@ -31,7 +31,7 @@  discard block
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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,10 +65,10 @@  discard block
 block discarded – undo
65 65
      */
66 66
     public function getMultiple(iterable $keys, mixed $default = null): iterable
67 67
     {
68
-        $result = [];
68
+        $result = [ ];
69 69
 
70 70
         foreach ($keys as $key) {
71
-            $result[$key] = $default;
71
+            $result[ $key ] = $default;
72 72
         }
73 73
 
74 74
         return $result;
Please login to merge, or discard this patch.
Handlers/ArrayHandler.php 2 patches
Indentation   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -88,7 +88,7 @@
 block discarded – undo
88 88
         if ($this->get($key) === null) {
89 89
             $this->set($key, 0);
90 90
 
91
-			return 0;
91
+   return 0;
92 92
         }
93 93
 
94 94
         $key = $this->_key($key);
Please login to merge, or discard this patch.
Spacing   +24 added lines, -24 removed lines patch added patch discarded remove patch
@@ -30,16 +30,16 @@  discard block
 block discarded – undo
30 30
      *
31 31
      * Structuré comme [clé => [exp => expiration, val => valeur]]
32 32
      */
33
-    protected array $data = [];
33
+    protected array $data = [ ];
34 34
 
35 35
     /**
36 36
      * {@inheritDoc}
37 37
      */
38
-    public function set(string $key, mixed $value, DateInterval|int|null $ttl = null): bool
38
+    public function set(string $key, mixed $value, DateInterval | int | null $ttl = null): bool
39 39
     {
40 40
         $key              = $this->_key($key);
41 41
         $expires          = time() + $this->duration($ttl);
42
-        $this->data[$key] = ['exp' => $expires, 'val' => $value];
42
+        $this->data[ $key ] = [ 'exp' => $expires, 'val' => $value ];
43 43
 
44 44
         return true;
45 45
     }
@@ -50,20 +50,20 @@  discard block
 block discarded – undo
50 50
     public function get(string $key, mixed $default = null): mixed
51 51
     {
52 52
         $key = $this->_key($key);
53
-        if (! isset($this->data[$key])) {
53
+        if (!isset($this->data[ $key ])) {
54 54
             return $default;
55 55
         }
56
-        $data = $this->data[$key];
56
+        $data = $this->data[ $key ];
57 57
 
58 58
         // Verifie l'expiration
59 59
         $now = time();
60
-        if ($data['exp'] <= $now) {
61
-            unset($this->data[$key]);
60
+        if ($data[ 'exp' ] <= $now) {
61
+            unset($this->data[ $key ]);
62 62
 
63 63
             return $default;
64 64
         }
65 65
 
66
-        return $data['val'];
66
+        return $data[ 'val' ];
67 67
     }
68 68
 
69 69
     /**
@@ -75,9 +75,9 @@  discard block
 block discarded – undo
75 75
             $this->set($key, 0);
76 76
         }
77 77
         $key = $this->_key($key);
78
-        $this->data[$key]['val'] += $offset;
78
+        $this->data[ $key ][ 'val' ] += $offset;
79 79
 
80
-        return $this->data[$key]['val'];
80
+        return $this->data[ $key ][ 'val' ];
81 81
     }
82 82
 
83 83
     /**
@@ -92,9 +92,9 @@  discard block
 block discarded – undo
92 92
         }
93 93
 
94 94
         $key = $this->_key($key);
95
-        $this->data[$key]['val'] -= $offset;
95
+        $this->data[ $key ][ 'val' ] -= $offset;
96 96
 
97
-        return $this->data[$key]['val'];
97
+        return $this->data[ $key ][ 'val' ];
98 98
     }
99 99
 
100 100
     /**
@@ -103,7 +103,7 @@  discard block
 block discarded – undo
103 103
     public function delete(string $key): bool
104 104
     {
105 105
         $key = $this->_key($key);
106
-        unset($this->data[$key]);
106
+        unset($this->data[ $key ]);
107 107
 
108 108
         return true;
109 109
     }
@@ -113,7 +113,7 @@  discard block
 block discarded – undo
113 113
      */
114 114
     public function clear(): bool
115 115
     {
116
-        $this->data = [];
116
+        $this->data = [ ];
117 117
 
118 118
         return true;
119 119
     }
@@ -123,15 +123,15 @@  discard block
 block discarded – undo
123 123
      */
124 124
     public function groups(): array
125 125
     {
126
-        $result = [];
126
+        $result = [ ];
127 127
 
128
-        foreach ($this->_config['groups'] as $group) {
129
-            $key = $this->_config['prefix'] . $group;
130
-            if (! isset($this->data[$key])) {
131
-                $this->data[$key] = ['exp' => PHP_INT_MAX, 'val' => 1];
128
+        foreach ($this->_config[ 'groups' ] as $group) {
129
+            $key = $this->_config[ 'prefix' ].$group;
130
+            if (!isset($this->data[ $key ])) {
131
+                $this->data[ $key ] = [ 'exp' => PHP_INT_MAX, 'val' => 1 ];
132 132
             }
133
-            $value    = $this->data[$key]['val'];
134
-            $result[] = $group . $value;
133
+            $value    = $this->data[ $key ][ 'val' ];
134
+            $result[ ] = $group.$value;
135 135
         }
136 136
 
137 137
         return $result;
@@ -142,9 +142,9 @@  discard block
 block discarded – undo
142 142
      */
143 143
     public function clearGroup(string $group): bool
144 144
     {
145
-        $key = $this->_config['prefix'] . $group;
146
-        if (isset($this->data[$key])) {
147
-            $this->data[$key]['val']++;
145
+        $key = $this->_config[ 'prefix' ].$group;
146
+        if (isset($this->data[ $key ])) {
147
+            $this->data[ $key ][ 'val' ]++;
148 148
         }
149 149
 
150 150
         return true;
Please login to merge, or discard this patch.