@@ -77,8 +77,8 @@ discard block |
||
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 | + if (!\is_string($name)){ |
|
82 | 82 | throw new InvalidArgumentException( |
83 | 83 | \vsprintf('Storage bucket config key must be a string, but %s defined', [ |
84 | 84 | \get_debug_type($name), |
@@ -87,7 +87,7 @@ discard block |
||
87 | 87 | } |
88 | 88 | |
89 | 89 | $serverName = $bucket['server'] ?? null; |
90 | - if (!\is_string($serverName)) { |
|
90 | + if (!\is_string($serverName)){ |
|
91 | 91 | throw new InvalidArgumentException( |
92 | 92 | \vsprintf('Storage bucket `%s.server` config key required and must be a string, but %s defined', [ |
93 | 93 | $name, |
@@ -97,7 +97,7 @@ discard block |
||
97 | 97 | } |
98 | 98 | |
99 | 99 | $server = $config['servers'][$serverName] ?? null; |
100 | - if (!\is_array($server)) { |
|
100 | + if (!\is_array($server)){ |
|
101 | 101 | throw new InvalidArgumentException( |
102 | 102 | \vsprintf('Storage bucket `%s` relates to non-existing server `%s`', [ |
103 | 103 | $name, |
@@ -107,7 +107,7 @@ discard block |
||
107 | 107 | } |
108 | 108 | |
109 | 109 | $adapter = $server['adapter'] ?? null; |
110 | - if (!\is_string($adapter)) { |
|
110 | + if (!\is_string($adapter)){ |
|
111 | 111 | throw new InvalidArgumentException( |
112 | 112 | \vsprintf('Storage server `%s.adapter` config key required and must be a string, but %s defined', [ |
113 | 113 | $serverName, |
@@ -120,7 +120,7 @@ discard block |
||
120 | 120 | |
121 | 121 | $this->adapters[$name] = $adapter; |
122 | 122 | |
123 | - if (isset($bucket['distribution'])) { |
|
123 | + if (isset($bucket['distribution'])){ |
|
124 | 124 | $this->distributions[$name] = $bucket['distribution']; |
125 | 125 | } |
126 | 126 | } |
@@ -138,9 +138,9 @@ discard block |
||
138 | 138 | |
139 | 139 | private function createS3Adapter(string $serverName, array $bucket, array $server, bool $async): FilesystemAdapter |
140 | 140 | { |
141 | - if (!$async && !\class_exists(Credentials::class)) { |
|
141 | + if (!$async && !\class_exists(Credentials::class)){ |
|
142 | 142 | throw new ConfigException( |
143 | - 'Can not create AWS credentials while creating "' . $serverName . '" server. ' |
|
143 | + 'Can not create AWS credentials while creating "'.$serverName.'" server. ' |
|
144 | 144 | . 'Perhaps you forgot to install the "league/flysystem-aws-s3-v3" package?' |
145 | 145 | ); |
146 | 146 | } |
@@ -148,8 +148,8 @@ discard block |
||
148 | 148 | $name = $bucket['bucket'] ?? $server['bucket']; |
149 | 149 | $visibility = $bucket['visibility'] ?? $server['visibility'] ?? Visibility::VISIBILITY_PUBLIC; |
150 | 150 | |
151 | - if ($async) { |
|
152 | - if (!\class_exists(AsyncAwsS3Adapter::class)) { |
|
151 | + if ($async){ |
|
152 | + if (!\class_exists(AsyncAwsS3Adapter::class)){ |
|
153 | 153 | throw new InvalidArgumentException( |
154 | 154 | 'Can not create async S3 client, please install "league/flysystem-async-aws-s3"' |
155 | 155 | ); |
@@ -163,7 +163,7 @@ discard block |
||
163 | 163 | ); |
164 | 164 | } |
165 | 165 | |
166 | - if (!\class_exists(AwsS3V3Adapter::class)) { |
|
166 | + if (!\class_exists(AwsS3V3Adapter::class)){ |
|
167 | 167 | throw new InvalidArgumentException( |
168 | 168 | 'Can not create S3 client, please install "league/flysystem-aws-s3-v3"' |
169 | 169 | ); |
@@ -179,7 +179,7 @@ discard block |
||
179 | 179 | |
180 | 180 | private function createLocalAdapter(string $serverName, array $bucket, array $server): FilesystemAdapter |
181 | 181 | { |
182 | - if (!\is_string($server['directory'] ?? null)) { |
|
182 | + if (!\is_string($server['directory'] ?? null)){ |
|
183 | 183 | throw new InvalidArgumentException( |
184 | 184 | \vsprintf('Storage server `%s.directory` config key required and must be a string, but %s defined', [ |
185 | 185 | $serverName, |
@@ -209,7 +209,7 @@ discard block |
||
209 | 209 | $adapter = $server['adapter']; |
210 | 210 | $isFilesystemAdapter = \is_subclass_of($adapter, FilesystemAdapter::class, true); |
211 | 211 | |
212 | - if (!$isFilesystemAdapter) { |
|
212 | + if (!$isFilesystemAdapter){ |
|
213 | 213 | throw new InvalidArgumentException( |
214 | 214 | \vsprintf('Storage server `%s` must be a class string of %s, but `%s` defined', [ |
215 | 215 | $serverName, |
@@ -219,9 +219,9 @@ discard block |
||
219 | 219 | ); |
220 | 220 | } |
221 | 221 | |
222 | - try { |
|
222 | + try{ |
|
223 | 223 | return new $adapter(...\array_values($server['options'] ?? [])); |
224 | - } catch (\Throwable $e) { |
|
224 | + }catch (\Throwable $e){ |
|
225 | 225 | $message = 'An error occurred while server `%s` initializing: %s'; |
226 | 226 | throw new InvalidArgumentException(\sprintf($message, $serverName, $e->getMessage()), 0, $e); |
227 | 227 | } |
@@ -234,7 +234,7 @@ discard block |
||
234 | 234 | 'endpoint' => $server['endpoint'] ?? null, |
235 | 235 | ] + ($server['options'] ?? []); |
236 | 236 | |
237 | - if (!$async) { |
|
237 | + if (!$async){ |
|
238 | 238 | $config['version'] = $server['version'] ?? 'latest'; |
239 | 239 | $config['credentials'] = new Credentials( |
240 | 240 | $server['key'] ?? null, |
@@ -77,8 +77,10 @@ discard block |
||
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 |
||
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 |
||
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 |
||
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 |
||
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 |
||
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 |
||
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 |
||
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 |
||
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 |
||
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 |
||
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 |
||
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, |