@@ -122,7 +122,7 @@ discard block |
||
122 | 122 | */ |
123 | 123 | private function normalizeServers(array $config): array |
124 | 124 | { |
125 | - if (! isset($config[self::SERVERS_KEY])) { |
|
125 | + if (!isset($config[self::SERVERS_KEY])){ |
|
126 | 126 | $config[self::SERVERS_KEY] = []; |
127 | 127 | |
128 | 128 | return $config; |
@@ -130,20 +130,20 @@ discard block |
||
130 | 130 | |
131 | 131 | $servers = $config[self::SERVERS_KEY]; |
132 | 132 | |
133 | - if (! \is_array($servers)) { |
|
133 | + if (!\is_array($servers)){ |
|
134 | 134 | $message = 'Storage servers list must be an array, but `%s` defined'; |
135 | 135 | throw new ConfigException(\sprintf($message, $this->valueToString($servers)), 0x01); |
136 | 136 | } |
137 | 137 | |
138 | - foreach ($servers as $name => $server) { |
|
139 | - if (! \is_string($name)) { |
|
138 | + foreach ($servers as $name => $server){ |
|
139 | + if (!\is_string($name)){ |
|
140 | 140 | $message = 'Storage server name must be a string, but %s defined'; |
141 | 141 | $message = \sprintf($message, $this->valueToString($name)); |
142 | 142 | |
143 | 143 | throw new ConfigException($message, 0x02); |
144 | 144 | } |
145 | 145 | |
146 | - if (! \is_array($server)) { |
|
146 | + if (!\is_array($server)){ |
|
147 | 147 | $message = 'Storage server `%s` config must be an array, but %s defined'; |
148 | 148 | $message = \sprintf($message, $name, $this->valueToString($server)); |
149 | 149 | |
@@ -152,8 +152,8 @@ discard block |
||
152 | 152 | |
153 | 153 | $adapter = $server['adapter'] ?? null; |
154 | 154 | |
155 | - if (! \is_string($adapter) || ! \is_subclass_of($adapter, FilesystemAdapter::class, true)) { |
|
156 | - $message = 'Storage server `%s` adapter must be a class ' . |
|
155 | + if (!\is_string($adapter) || !\is_subclass_of($adapter, FilesystemAdapter::class, true)){ |
|
156 | + $message = 'Storage server `%s` adapter must be a class '. |
|
157 | 157 | 'string that implements %s interface, but %s defined' |
158 | 158 | ; |
159 | 159 | |
@@ -162,7 +162,7 @@ discard block |
||
162 | 162 | throw new ConfigException($message, 0x04); |
163 | 163 | } |
164 | 164 | |
165 | - if (isset($server['options']) && ! \is_array($server['options'])) { |
|
165 | + if (isset($server['options']) && !\is_array($server['options'])){ |
|
166 | 166 | $message = 'Storage server `%s` options must be an array, but %s defined'; |
167 | 167 | $message = \sprintf($message, $name, $this->valueToString($server['options'])); |
168 | 168 | |
@@ -183,7 +183,7 @@ discard block |
||
183 | 183 | */ |
184 | 184 | private function normalizeBuckets(array $config): array |
185 | 185 | { |
186 | - if (! isset($config[self::STORAGES_KEY])) { |
|
186 | + if (!isset($config[self::STORAGES_KEY])){ |
|
187 | 187 | $config[self::STORAGES_KEY] = []; |
188 | 188 | |
189 | 189 | return $config; |
@@ -191,20 +191,20 @@ discard block |
||
191 | 191 | |
192 | 192 | $buckets = $config[self::STORAGES_KEY]; |
193 | 193 | |
194 | - if (! \is_array($buckets)) { |
|
194 | + if (!\is_array($buckets)){ |
|
195 | 195 | $message = 'Storage buckets list must be an array, but `%s` defined'; |
196 | 196 | throw new ConfigException(\sprintf($message, $this->valueToString($buckets)), 0x06); |
197 | 197 | } |
198 | 198 | |
199 | - foreach ($buckets as $name => $bucket) { |
|
200 | - if (! \is_string($name)) { |
|
199 | + foreach ($buckets as $name => $bucket){ |
|
200 | + if (!\is_string($name)){ |
|
201 | 201 | $message = 'Storage bucket name must be a string, but %s defined'; |
202 | 202 | $message = \sprintf($message, $this->valueToString($name)); |
203 | 203 | |
204 | 204 | throw new ConfigException($message, 0x07); |
205 | 205 | } |
206 | 206 | |
207 | - if (! \is_array($bucket)) { |
|
207 | + if (!\is_array($bucket)){ |
|
208 | 208 | $message = 'Storage bucket `%s` config must be an array, but %s defined'; |
209 | 209 | $message = \sprintf($message, $name, $this->valueToString($bucket)); |
210 | 210 | |
@@ -213,14 +213,14 @@ discard block |
||
213 | 213 | |
214 | 214 | $server = $bucket['server'] ?? null; |
215 | 215 | |
216 | - if (! \is_string($server)) { |
|
216 | + if (!\is_string($server)){ |
|
217 | 217 | $message = 'Storage server of bucket `%s` must be a string, but %s defined'; |
218 | 218 | $message = \sprintf($message, $name, $this->valueToString($server)); |
219 | 219 | |
220 | 220 | throw new ConfigException($message, 0x09); |
221 | 221 | } |
222 | 222 | |
223 | - if (! isset($config[self::SERVERS_KEY][$server])) { |
|
223 | + if (!isset($config[self::SERVERS_KEY][$server])){ |
|
224 | 224 | $variants = \implode(', ', \array_keys($config[self::SERVERS_KEY] ?? [])); |
225 | 225 | $message = 'Storage server `%s` of bucket `%s` has not been defined, one of [%s] required'; |
226 | 226 | $message = \sprintf($message, $server, $name, $variants); |
@@ -228,7 +228,7 @@ discard block |
||
228 | 228 | throw new ConfigException($message, 0x0A); |
229 | 229 | } |
230 | 230 | |
231 | - if (isset($bucket['options']) && ! \is_array($bucket['options'])) { |
|
231 | + if (isset($bucket['options']) && !\is_array($bucket['options'])){ |
|
232 | 232 | $message = 'Storage bucket `%s` options must be an array, but %s defined'; |
233 | 233 | $message = \sprintf($message, $name, $this->valueToString($bucket['options'])); |
234 | 234 | |
@@ -249,7 +249,7 @@ discard block |
||
249 | 249 | */ |
250 | 250 | private function normalizeTemporaryDirectory(array $config): array |
251 | 251 | { |
252 | - if (! isset($config[self::TMP_DIR_KEY]) ) { |
|
252 | + if (!isset($config[self::TMP_DIR_KEY])){ |
|
253 | 253 | $config[self::TMP_DIR_KEY] = \sys_get_temp_dir(); |
254 | 254 | |
255 | 255 | return $config; |
@@ -257,17 +257,17 @@ discard block |
||
257 | 257 | |
258 | 258 | $directory = $config[self::TMP_DIR_KEY]; |
259 | 259 | |
260 | - if (! \is_string($directory)) { |
|
260 | + if (!\is_string($directory)){ |
|
261 | 261 | $message = 'Storage temporary directory must be a string, but `%s` defined'; |
262 | 262 | throw new ConfigException(\sprintf($message, $this->valueToString($directory)), 0x0C); |
263 | 263 | } |
264 | 264 | |
265 | - if (! \is_dir($directory)) { |
|
265 | + if (!\is_dir($directory)){ |
|
266 | 266 | $message = 'Storage temporary directory `%s` must be a valid directory'; |
267 | 267 | throw new ConfigException(\sprintf($message, $directory), 0x0D); |
268 | 268 | } |
269 | 269 | |
270 | - if (! \is_writable($directory)) { |
|
270 | + if (!\is_writable($directory)){ |
|
271 | 271 | $message = 'Storage temporary directory `%s` must be writable'; |
272 | 272 | throw new ConfigException(\sprintf($message, $directory), 0x0E); |
273 | 273 | } |
@@ -283,7 +283,7 @@ discard block |
||
283 | 283 | { |
284 | 284 | $suffix = \is_scalar($value) ? "($value)" : (string)$value; |
285 | 285 | |
286 | - return \get_debug_type($value) . $suffix; |
|
286 | + return \get_debug_type($value).$suffix; |
|
287 | 287 | } |
288 | 288 | |
289 | 289 | /** |
@@ -331,19 +331,19 @@ discard block |
||
331 | 331 | */ |
332 | 332 | public function buildFileSystemInfo(string $fs, ?bool $force = false): FileSystemInfoInterface |
333 | 333 | { |
334 | - if (!$this->hasBucket($fs)) { |
|
334 | + if (!$this->hasBucket($fs)){ |
|
335 | 335 | throw new ConfigException( |
336 | 336 | \sprintf('Bucket `%s` was not found', $fs) |
337 | 337 | ); |
338 | 338 | } |
339 | 339 | |
340 | - if (!$force && array_key_exists($fs, $this->fileSystemsInfoList)) { |
|
340 | + if (!$force && array_key_exists($fs, $this->fileSystemsInfoList)){ |
|
341 | 341 | return $this->fileSystemsInfoList[$fs]; |
342 | 342 | } |
343 | 343 | |
344 | 344 | $bucketInfo = $this->buildBucketInfo($fs); |
345 | 345 | |
346 | - if (!$this->hasServer($bucketInfo->getServer())) { |
|
346 | + if (!$this->hasServer($bucketInfo->getServer())){ |
|
347 | 347 | throw new ConfigException( |
348 | 348 | \sprintf( |
349 | 349 | 'Server `%s` info for filesystem `%s` was not detected', |
@@ -355,7 +355,7 @@ discard block |
||
355 | 355 | |
356 | 356 | $serverInfo = $this->config[self::SERVERS_KEY][$bucketInfo->getServer()]; |
357 | 357 | |
358 | - switch ($this->extractServerAdapter($serverInfo)) { |
|
358 | + switch ($this->extractServerAdapter($serverInfo)){ |
|
359 | 359 | case \League\Flysystem\Local\LocalFilesystemAdapter::class: |
360 | 360 | $fsInfoDTO = new FileSystemInfo\LocalInfo($fs, $serverInfo); |
361 | 361 | break; |
@@ -389,13 +389,13 @@ discard block |
||
389 | 389 | */ |
390 | 390 | public function buildBucketInfo(string $bucketLabel, ?bool $force = false): BucketInfoInterface |
391 | 391 | { |
392 | - if (!$this->hasBucket($bucketLabel)) { |
|
392 | + if (!$this->hasBucket($bucketLabel)){ |
|
393 | 393 | throw new StorageException( |
394 | 394 | \sprintf('Bucket `%s` was not found', $bucketLabel) |
395 | 395 | ); |
396 | 396 | } |
397 | 397 | |
398 | - if (!$force && array_key_exists($bucketLabel, $this->bucketsInfoList)) { |
|
398 | + if (!$force && array_key_exists($bucketLabel, $this->bucketsInfoList)){ |
|
399 | 399 | return $this->bucketsInfoList[$bucketLabel]; |
400 | 400 | } |
401 | 401 |
@@ -122,7 +122,8 @@ discard block |
||
122 | 122 | */ |
123 | 123 | private function normalizeServers(array $config): array |
124 | 124 | { |
125 | - if (! isset($config[self::SERVERS_KEY])) { |
|
125 | + if (! isset($config[self::SERVERS_KEY])) |
|
126 | + { |
|
126 | 127 | $config[self::SERVERS_KEY] = []; |
127 | 128 | |
128 | 129 | return $config; |
@@ -130,20 +131,24 @@ discard block |
||
130 | 131 | |
131 | 132 | $servers = $config[self::SERVERS_KEY]; |
132 | 133 | |
133 | - if (! \is_array($servers)) { |
|
134 | + if (! \is_array($servers)) |
|
135 | + { |
|
134 | 136 | $message = 'Storage servers list must be an array, but `%s` defined'; |
135 | 137 | throw new ConfigException(\sprintf($message, $this->valueToString($servers)), 0x01); |
136 | 138 | } |
137 | 139 | |
138 | - foreach ($servers as $name => $server) { |
|
139 | - if (! \is_string($name)) { |
|
140 | + foreach ($servers as $name => $server) |
|
141 | + { |
|
142 | + if (! \is_string($name)) |
|
143 | + { |
|
140 | 144 | $message = 'Storage server name must be a string, but %s defined'; |
141 | 145 | $message = \sprintf($message, $this->valueToString($name)); |
142 | 146 | |
143 | 147 | throw new ConfigException($message, 0x02); |
144 | 148 | } |
145 | 149 | |
146 | - if (! \is_array($server)) { |
|
150 | + if (! \is_array($server)) |
|
151 | + { |
|
147 | 152 | $message = 'Storage server `%s` config must be an array, but %s defined'; |
148 | 153 | $message = \sprintf($message, $name, $this->valueToString($server)); |
149 | 154 | |
@@ -152,7 +157,8 @@ discard block |
||
152 | 157 | |
153 | 158 | $adapter = $server['adapter'] ?? null; |
154 | 159 | |
155 | - if (! \is_string($adapter) || ! \is_subclass_of($adapter, FilesystemAdapter::class, true)) { |
|
160 | + if (! \is_string($adapter) || ! \is_subclass_of($adapter, FilesystemAdapter::class, true)) |
|
161 | + { |
|
156 | 162 | $message = 'Storage server `%s` adapter must be a class ' . |
157 | 163 | 'string that implements %s interface, but %s defined' |
158 | 164 | ; |
@@ -162,7 +168,8 @@ discard block |
||
162 | 168 | throw new ConfigException($message, 0x04); |
163 | 169 | } |
164 | 170 | |
165 | - if (isset($server['options']) && ! \is_array($server['options'])) { |
|
171 | + if (isset($server['options']) && ! \is_array($server['options'])) |
|
172 | + { |
|
166 | 173 | $message = 'Storage server `%s` options must be an array, but %s defined'; |
167 | 174 | $message = \sprintf($message, $name, $this->valueToString($server['options'])); |
168 | 175 | |
@@ -183,7 +190,8 @@ discard block |
||
183 | 190 | */ |
184 | 191 | private function normalizeBuckets(array $config): array |
185 | 192 | { |
186 | - if (! isset($config[self::STORAGES_KEY])) { |
|
193 | + if (! isset($config[self::STORAGES_KEY])) |
|
194 | + { |
|
187 | 195 | $config[self::STORAGES_KEY] = []; |
188 | 196 | |
189 | 197 | return $config; |
@@ -191,20 +199,24 @@ discard block |
||
191 | 199 | |
192 | 200 | $buckets = $config[self::STORAGES_KEY]; |
193 | 201 | |
194 | - if (! \is_array($buckets)) { |
|
202 | + if (! \is_array($buckets)) |
|
203 | + { |
|
195 | 204 | $message = 'Storage buckets list must be an array, but `%s` defined'; |
196 | 205 | throw new ConfigException(\sprintf($message, $this->valueToString($buckets)), 0x06); |
197 | 206 | } |
198 | 207 | |
199 | - foreach ($buckets as $name => $bucket) { |
|
200 | - if (! \is_string($name)) { |
|
208 | + foreach ($buckets as $name => $bucket) |
|
209 | + { |
|
210 | + if (! \is_string($name)) |
|
211 | + { |
|
201 | 212 | $message = 'Storage bucket name must be a string, but %s defined'; |
202 | 213 | $message = \sprintf($message, $this->valueToString($name)); |
203 | 214 | |
204 | 215 | throw new ConfigException($message, 0x07); |
205 | 216 | } |
206 | 217 | |
207 | - if (! \is_array($bucket)) { |
|
218 | + if (! \is_array($bucket)) |
|
219 | + { |
|
208 | 220 | $message = 'Storage bucket `%s` config must be an array, but %s defined'; |
209 | 221 | $message = \sprintf($message, $name, $this->valueToString($bucket)); |
210 | 222 | |
@@ -213,14 +225,16 @@ discard block |
||
213 | 225 | |
214 | 226 | $server = $bucket['server'] ?? null; |
215 | 227 | |
216 | - if (! \is_string($server)) { |
|
228 | + if (! \is_string($server)) |
|
229 | + { |
|
217 | 230 | $message = 'Storage server of bucket `%s` must be a string, but %s defined'; |
218 | 231 | $message = \sprintf($message, $name, $this->valueToString($server)); |
219 | 232 | |
220 | 233 | throw new ConfigException($message, 0x09); |
221 | 234 | } |
222 | 235 | |
223 | - if (! isset($config[self::SERVERS_KEY][$server])) { |
|
236 | + if (! isset($config[self::SERVERS_KEY][$server])) |
|
237 | + { |
|
224 | 238 | $variants = \implode(', ', \array_keys($config[self::SERVERS_KEY] ?? [])); |
225 | 239 | $message = 'Storage server `%s` of bucket `%s` has not been defined, one of [%s] required'; |
226 | 240 | $message = \sprintf($message, $server, $name, $variants); |
@@ -228,7 +242,8 @@ discard block |
||
228 | 242 | throw new ConfigException($message, 0x0A); |
229 | 243 | } |
230 | 244 | |
231 | - if (isset($bucket['options']) && ! \is_array($bucket['options'])) { |
|
245 | + if (isset($bucket['options']) && ! \is_array($bucket['options'])) |
|
246 | + { |
|
232 | 247 | $message = 'Storage bucket `%s` options must be an array, but %s defined'; |
233 | 248 | $message = \sprintf($message, $name, $this->valueToString($bucket['options'])); |
234 | 249 | |
@@ -249,7 +264,8 @@ discard block |
||
249 | 264 | */ |
250 | 265 | private function normalizeTemporaryDirectory(array $config): array |
251 | 266 | { |
252 | - if (! isset($config[self::TMP_DIR_KEY]) ) { |
|
267 | + if (! isset($config[self::TMP_DIR_KEY]) ) |
|
268 | + { |
|
253 | 269 | $config[self::TMP_DIR_KEY] = \sys_get_temp_dir(); |
254 | 270 | |
255 | 271 | return $config; |
@@ -257,17 +273,20 @@ discard block |
||
257 | 273 | |
258 | 274 | $directory = $config[self::TMP_DIR_KEY]; |
259 | 275 | |
260 | - if (! \is_string($directory)) { |
|
276 | + if (! \is_string($directory)) |
|
277 | + { |
|
261 | 278 | $message = 'Storage temporary directory must be a string, but `%s` defined'; |
262 | 279 | throw new ConfigException(\sprintf($message, $this->valueToString($directory)), 0x0C); |
263 | 280 | } |
264 | 281 | |
265 | - if (! \is_dir($directory)) { |
|
282 | + if (! \is_dir($directory)) |
|
283 | + { |
|
266 | 284 | $message = 'Storage temporary directory `%s` must be a valid directory'; |
267 | 285 | throw new ConfigException(\sprintf($message, $directory), 0x0D); |
268 | 286 | } |
269 | 287 | |
270 | - if (! \is_writable($directory)) { |
|
288 | + if (! \is_writable($directory)) |
|
289 | + { |
|
271 | 290 | $message = 'Storage temporary directory `%s` must be writable'; |
272 | 291 | throw new ConfigException(\sprintf($message, $directory), 0x0E); |
273 | 292 | } |
@@ -331,19 +350,22 @@ discard block |
||
331 | 350 | */ |
332 | 351 | public function buildFileSystemInfo(string $fs, ?bool $force = false): FileSystemInfoInterface |
333 | 352 | { |
334 | - if (!$this->hasBucket($fs)) { |
|
353 | + if (!$this->hasBucket($fs)) |
|
354 | + { |
|
335 | 355 | throw new ConfigException( |
336 | 356 | \sprintf('Bucket `%s` was not found', $fs) |
337 | 357 | ); |
338 | 358 | } |
339 | 359 | |
340 | - if (!$force && array_key_exists($fs, $this->fileSystemsInfoList)) { |
|
360 | + if (!$force && array_key_exists($fs, $this->fileSystemsInfoList)) |
|
361 | + { |
|
341 | 362 | return $this->fileSystemsInfoList[$fs]; |
342 | 363 | } |
343 | 364 | |
344 | 365 | $bucketInfo = $this->buildBucketInfo($fs); |
345 | 366 | |
346 | - if (!$this->hasServer($bucketInfo->getServer())) { |
|
367 | + if (!$this->hasServer($bucketInfo->getServer())) |
|
368 | + { |
|
347 | 369 | throw new ConfigException( |
348 | 370 | \sprintf( |
349 | 371 | 'Server `%s` info for filesystem `%s` was not detected', |
@@ -355,7 +377,8 @@ discard block |
||
355 | 377 | |
356 | 378 | $serverInfo = $this->config[self::SERVERS_KEY][$bucketInfo->getServer()]; |
357 | 379 | |
358 | - switch ($this->extractServerAdapter($serverInfo)) { |
|
380 | + switch ($this->extractServerAdapter($serverInfo)) |
|
381 | + { |
|
359 | 382 | case \League\Flysystem\Local\LocalFilesystemAdapter::class: |
360 | 383 | $fsInfoDTO = new FileSystemInfo\LocalInfo($fs, $serverInfo); |
361 | 384 | break; |
@@ -389,13 +412,15 @@ discard block |
||
389 | 412 | */ |
390 | 413 | public function buildBucketInfo(string $bucketLabel, ?bool $force = false): BucketInfoInterface |
391 | 414 | { |
392 | - if (!$this->hasBucket($bucketLabel)) { |
|
415 | + if (!$this->hasBucket($bucketLabel)) |
|
416 | + { |
|
393 | 417 | throw new StorageException( |
394 | 418 | \sprintf('Bucket `%s` was not found', $bucketLabel) |
395 | 419 | ); |
396 | 420 | } |
397 | 421 | |
398 | - if (!$force && array_key_exists($bucketLabel, $this->bucketsInfoList)) { |
|
422 | + if (!$force && array_key_exists($bucketLabel, $this->bucketsInfoList)) |
|
423 | + { |
|
399 | 424 | return $this->bucketsInfoList[$bucketLabel]; |
400 | 425 | } |
401 | 426 |