Passed
Push — master ( 5c4bac...e50301 )
by butschster
05:42 queued 19s
created
src/Storage/src/Config/StorageConfig.php 1 patch
Braces   +31 added lines, -15 removed lines patch added patch discarded remove patch
@@ -77,8 +77,10 @@  discard block
 block discarded – undo
77 77
 
78 78
     private function bootStorages(array $config): void
79 79
     {
80
-        foreach ($config['buckets'] as $name => $bucket) {
81
-            if (!\is_string($name)) {
80
+        foreach ($config['buckets'] as $name => $bucket)
81
+        {
82
+            if (!\is_string($name))
83
+            {
82 84
                 throw new InvalidArgumentException(
83 85
                     \vsprintf('Storage bucket config key must be a string, but %s defined', [
84 86
                         \get_debug_type($name),
@@ -87,7 +89,8 @@  discard block
 block discarded – undo
87 89
             }
88 90
 
89 91
             $serverName = $bucket['server'] ?? null;
90
-            if (!\is_string($serverName)) {
92
+            if (!\is_string($serverName))
93
+            {
91 94
                 throw new InvalidArgumentException(
92 95
                     \vsprintf('Storage bucket `%s.server` config key required and must be a string, but %s defined', [
93 96
                         $name,
@@ -97,7 +100,8 @@  discard block
 block discarded – undo
97 100
             }
98 101
 
99 102
             $server = $config['servers'][$serverName] ?? null;
100
-            if (!\is_array($server)) {
103
+            if (!\is_array($server))
104
+            {
101 105
                 throw new InvalidArgumentException(
102 106
                     \vsprintf('Storage bucket `%s` relates to non-existing server `%s`', [
103 107
                         $name,
@@ -107,7 +111,8 @@  discard block
 block discarded – undo
107 111
             }
108 112
 
109 113
             $adapter = $server['adapter'] ?? null;
110
-            if (!\is_string($adapter)) {
114
+            if (!\is_string($adapter))
115
+            {
111 116
                 throw new InvalidArgumentException(
112 117
                     \vsprintf('Storage server `%s.adapter` config key required and must be a string, but %s defined', [
113 118
                         $serverName,
@@ -120,7 +125,8 @@  discard block
 block discarded – undo
120 125
 
121 126
             $this->adapters[$name] = $adapter;
122 127
 
123
-            if (isset($bucket['distribution'])) {
128
+            if (isset($bucket['distribution']))
129
+            {
124 130
                 $this->distributions[$name] = $bucket['distribution'];
125 131
             }
126 132
         }
@@ -138,7 +144,8 @@  discard block
 block discarded – undo
138 144
 
139 145
     private function createS3Adapter(string $serverName, array $bucket, array $server, bool $async): FilesystemAdapter
140 146
     {
141
-        if (!$async && !\class_exists(Credentials::class)) {
147
+        if (!$async && !\class_exists(Credentials::class))
148
+        {
142 149
             throw new ConfigException(
143 150
                 'Can not create AWS credentials while creating "' . $serverName . '" server. '
144 151
                 . 'Perhaps you forgot to install the "league/flysystem-aws-s3-v3" package?'
@@ -148,8 +155,10 @@  discard block
 block discarded – undo
148 155
         $name = $bucket['bucket'] ?? $server['bucket'];
149 156
         $visibility = $bucket['visibility'] ?? $server['visibility'] ?? Visibility::VISIBILITY_PUBLIC;
150 157
 
151
-        if ($async) {
152
-            if (!\class_exists(AsyncAwsS3Adapter::class)) {
158
+        if ($async)
159
+        {
160
+            if (!\class_exists(AsyncAwsS3Adapter::class))
161
+            {
153 162
                 throw new InvalidArgumentException(
154 163
                     'Can not create async S3 client, please install "league/flysystem-async-aws-s3"'
155 164
                 );
@@ -163,7 +172,8 @@  discard block
 block discarded – undo
163 172
             );
164 173
         }
165 174
 
166
-        if (!\class_exists(AwsS3V3Adapter::class)) {
175
+        if (!\class_exists(AwsS3V3Adapter::class))
176
+        {
167 177
             throw new InvalidArgumentException(
168 178
                 'Can not create S3 client, please install "league/flysystem-aws-s3-v3"'
169 179
             );
@@ -179,7 +189,8 @@  discard block
 block discarded – undo
179 189
 
180 190
     private function createLocalAdapter(string $serverName, array $bucket, array $server): FilesystemAdapter
181 191
     {
182
-        if (!\is_string($server['directory'] ?? null)) {
192
+        if (!\is_string($server['directory'] ?? null))
193
+        {
183 194
             throw new InvalidArgumentException(
184 195
                 \vsprintf('Storage server `%s.directory` config key required and must be a string, but %s defined', [
185 196
                     $serverName,
@@ -209,7 +220,8 @@  discard block
 block discarded – undo
209 220
         $adapter = $server['adapter'];
210 221
         $isFilesystemAdapter = \is_subclass_of($adapter, FilesystemAdapter::class, true);
211 222
 
212
-        if (!$isFilesystemAdapter) {
223
+        if (!$isFilesystemAdapter)
224
+        {
213 225
             throw new InvalidArgumentException(
214 226
                 \vsprintf('Storage server `%s` must be a class string of %s, but `%s` defined', [
215 227
                     $serverName,
@@ -219,9 +231,12 @@  discard block
 block discarded – undo
219 231
             );
220 232
         }
221 233
 
222
-        try {
234
+        try
235
+        {
223 236
             return new $adapter(...\array_values($server['options'] ?? []));
224
-        } catch (\Throwable $e) {
237
+        }
238
+        catch (\Throwable $e)
239
+        {
225 240
             $message = 'An error occurred while server `%s` initializing: %s';
226 241
             throw new InvalidArgumentException(\sprintf($message, $serverName, $e->getMessage()), 0, $e);
227 242
         }
@@ -234,7 +249,8 @@  discard block
 block discarded – undo
234 249
             'endpoint' => $server['endpoint'] ?? null,
235 250
         ] + ($server['options'] ?? []);
236 251
 
237
-        if (!$async) {
252
+        if (!$async)
253
+        {
238 254
             $config['version'] = $server['version'] ?? 'latest';
239 255
             $config['credentials'] = new Credentials(
240 256
                 $server['key'] ?? null,
Please login to merge, or discard this patch.