@@ -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 (!\class_exists(Credentials::class)) { |
|
141 | + if (!\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 | } |
@@ -160,8 +160,8 @@ discard block |
||
160 | 160 | $name = $bucket['bucket'] ?? $server['bucket']; |
161 | 161 | $visibility = $bucket['visibility'] ?? $server['bucket'] ?? Visibility::VISIBILITY_PUBLIC; |
162 | 162 | |
163 | - if ($async) { |
|
164 | - if (!\class_exists(AsyncAwsS3Adapter::class)) { |
|
163 | + if ($async){ |
|
164 | + if (!\class_exists(AsyncAwsS3Adapter::class)){ |
|
165 | 165 | throw new InvalidArgumentException( |
166 | 166 | 'Can not create async S3 client, please install "league/flysystem-async-aws-s3"' |
167 | 167 | ); |
@@ -177,7 +177,7 @@ discard block |
||
177 | 177 | ); |
178 | 178 | } |
179 | 179 | |
180 | - if (!\class_exists(AwsS3V3Adapter::class)) { |
|
180 | + if (!\class_exists(AwsS3V3Adapter::class)){ |
|
181 | 181 | throw new InvalidArgumentException( |
182 | 182 | 'Can not create S3 client, please install "league/flysystem-aws-s3-v3"' |
183 | 183 | ); |
@@ -195,7 +195,7 @@ discard block |
||
195 | 195 | |
196 | 196 | private function createLocalAdapter(string $serverName, array $bucket, array $server): FilesystemAdapter |
197 | 197 | { |
198 | - if (!\is_string($server['directory'] ?? null)) { |
|
198 | + if (!\is_string($server['directory'] ?? null)){ |
|
199 | 199 | throw new InvalidArgumentException( |
200 | 200 | \vsprintf('Storage server `%s.directory` config key required and must be a string, but %s defined', [ |
201 | 201 | $serverName, |
@@ -225,7 +225,7 @@ discard block |
||
225 | 225 | $adapter = $server['adapter']; |
226 | 226 | $isFilesystemAdapter = \is_subclass_of($adapter, FilesystemAdapter::class, true); |
227 | 227 | |
228 | - if (!$isFilesystemAdapter) { |
|
228 | + if (!$isFilesystemAdapter){ |
|
229 | 229 | throw new InvalidArgumentException( |
230 | 230 | \vsprintf('Storage server `%s` must be a class string of %s, but `%s` defined', [ |
231 | 231 | $serverName, |
@@ -235,9 +235,9 @@ discard block |
||
235 | 235 | ); |
236 | 236 | } |
237 | 237 | |
238 | - try { |
|
238 | + try{ |
|
239 | 239 | return new $adapter(...\array_values($server['options'] ?? [])); |
240 | - } catch (\Throwable $e) { |
|
240 | + }catch (\Throwable $e){ |
|
241 | 241 | $message = 'An error occurred while server `%s` initializing: %s'; |
242 | 242 | throw new InvalidArgumentException(\sprintf($message, $serverName, $e->getMessage()), 0, $e); |
243 | 243 | } |
@@ -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 (!\class_exists(Credentials::class)) { |
|
147 | + if (!\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?' |
@@ -160,8 +167,10 @@ discard block |
||
160 | 167 | $name = $bucket['bucket'] ?? $server['bucket']; |
161 | 168 | $visibility = $bucket['visibility'] ?? $server['bucket'] ?? Visibility::VISIBILITY_PUBLIC; |
162 | 169 | |
163 | - if ($async) { |
|
164 | - if (!\class_exists(AsyncAwsS3Adapter::class)) { |
|
170 | + if ($async) |
|
171 | + { |
|
172 | + if (!\class_exists(AsyncAwsS3Adapter::class)) |
|
173 | + { |
|
165 | 174 | throw new InvalidArgumentException( |
166 | 175 | 'Can not create async S3 client, please install "league/flysystem-async-aws-s3"' |
167 | 176 | ); |
@@ -177,7 +186,8 @@ discard block |
||
177 | 186 | ); |
178 | 187 | } |
179 | 188 | |
180 | - if (!\class_exists(AwsS3V3Adapter::class)) { |
|
189 | + if (!\class_exists(AwsS3V3Adapter::class)) |
|
190 | + { |
|
181 | 191 | throw new InvalidArgumentException( |
182 | 192 | 'Can not create S3 client, please install "league/flysystem-aws-s3-v3"' |
183 | 193 | ); |
@@ -195,7 +205,8 @@ discard block |
||
195 | 205 | |
196 | 206 | private function createLocalAdapter(string $serverName, array $bucket, array $server): FilesystemAdapter |
197 | 207 | { |
198 | - if (!\is_string($server['directory'] ?? null)) { |
|
208 | + if (!\is_string($server['directory'] ?? null)) |
|
209 | + { |
|
199 | 210 | throw new InvalidArgumentException( |
200 | 211 | \vsprintf('Storage server `%s.directory` config key required and must be a string, but %s defined', [ |
201 | 212 | $serverName, |
@@ -225,7 +236,8 @@ discard block |
||
225 | 236 | $adapter = $server['adapter']; |
226 | 237 | $isFilesystemAdapter = \is_subclass_of($adapter, FilesystemAdapter::class, true); |
227 | 238 | |
228 | - if (!$isFilesystemAdapter) { |
|
239 | + if (!$isFilesystemAdapter) |
|
240 | + { |
|
229 | 241 | throw new InvalidArgumentException( |
230 | 242 | \vsprintf('Storage server `%s` must be a class string of %s, but `%s` defined', [ |
231 | 243 | $serverName, |
@@ -235,9 +247,12 @@ discard block |
||
235 | 247 | ); |
236 | 248 | } |
237 | 249 | |
238 | - try { |
|
250 | + try |
|
251 | + { |
|
239 | 252 | return new $adapter(...\array_values($server['options'] ?? [])); |
240 | - } catch (\Throwable $e) { |
|
253 | + } |
|
254 | + catch (\Throwable $e) |
|
255 | + { |
|
241 | 256 | $message = 'An error occurred while server `%s` initializing: %s'; |
242 | 257 | throw new InvalidArgumentException(\sprintf($message, $serverName, $e->getMessage()), 0, $e); |
243 | 258 | } |
@@ -21,7 +21,7 @@ |
||
21 | 21 | protected FilesystemOperator $fs, |
22 | 22 | protected ?string $name = null, |
23 | 23 | protected ?UriResolverInterface $resolver = null |
24 | - ) { |
|
24 | + ){ |
|
25 | 25 | } |
26 | 26 | |
27 | 27 | public function getName(): ?string |
@@ -28,7 +28,7 @@ |
||
28 | 28 | /** |
29 | 29 | * @throws InvalidArgumentException |
30 | 30 | */ |
31 | - public function file(string|\Stringable $id): FileInterface; |
|
31 | + public function file(string | \Stringable $id): FileInterface; |
|
32 | 32 | |
33 | 33 | public function withDefault(string $name): self; |
34 | 34 | } |
@@ -55,14 +55,14 @@ discard block |
||
55 | 55 | { |
56 | 56 | $name ??= $this->default; |
57 | 57 | |
58 | - if (!isset($this->buckets[$name])) { |
|
58 | + if (!isset($this->buckets[$name])){ |
|
59 | 59 | throw new InvalidArgumentException(\sprintf(self::ERROR_NOT_FOUND, $name)); |
60 | 60 | } |
61 | 61 | |
62 | 62 | return $this->buckets[$name]; |
63 | 63 | } |
64 | 64 | |
65 | - public function file(string|\Stringable $id): FileInterface |
|
65 | + public function file(string | \Stringable $id): FileInterface |
|
66 | 66 | { |
67 | 67 | [$bucket, $file] = $this->parseUri($id); |
68 | 68 | |
@@ -71,7 +71,7 @@ discard block |
||
71 | 71 | |
72 | 72 | public function add(string $name, BucketInterface $storage, bool $overwrite = false): void |
73 | 73 | { |
74 | - if (!$overwrite && isset($this->buckets[$name])) { |
|
74 | + if (!$overwrite && isset($this->buckets[$name])){ |
|
75 | 75 | throw new \InvalidArgumentException(\sprintf(self::ERROR_REDEFINITION, $name)); |
76 | 76 | } |
77 | 77 | |
@@ -92,35 +92,35 @@ discard block |
||
92 | 92 | * @return array{0: string|null, 1: string} |
93 | 93 | * @throws InvalidArgumentException |
94 | 94 | */ |
95 | - protected function parseUri(string|\Stringable $uri, bool $withScheme = true): array |
|
95 | + protected function parseUri(string | \Stringable $uri, bool $withScheme = true): array |
|
96 | 96 | { |
97 | 97 | $uri = $this->uriToString($uri); |
98 | 98 | $result = \parse_url($uri); |
99 | 99 | |
100 | - if ($result === false) { |
|
100 | + if ($result === false){ |
|
101 | 101 | $message = 'URI argument must be a valid URI in "[STORAGE]://[PATH_TO_FILE]" format, but `%s` given'; |
102 | 102 | throw new InvalidArgumentException(\sprintf($message, $uri)); |
103 | 103 | } |
104 | 104 | |
105 | - if (!isset($result['scheme'])) { |
|
105 | + if (!isset($result['scheme'])){ |
|
106 | 106 | $result['scheme'] = $withScheme ? $this->default : null; |
107 | 107 | } |
108 | 108 | |
109 | - if (!isset($result['host'])) { |
|
109 | + if (!isset($result['host'])){ |
|
110 | 110 | $result['host'] = ''; |
111 | 111 | } |
112 | 112 | |
113 | 113 | return [ |
114 | 114 | $result['scheme'] ?? null, |
115 | - $result['host'] . \rtrim($result['path'] ?? '', '/'), |
|
115 | + $result['host'].\rtrim($result['path'] ?? '', '/'), |
|
116 | 116 | ]; |
117 | 117 | } |
118 | 118 | |
119 | - private function uriToString(string|\Stringable $uri): string |
|
119 | + private function uriToString(string | \Stringable $uri): string |
|
120 | 120 | { |
121 | 121 | return match (true) { |
122 | 122 | \is_string($uri) => $uri, |
123 | - default => (string) $uri |
|
123 | + default => (string)$uri |
|
124 | 124 | }; |
125 | 125 | } |
126 | 126 | } |
@@ -55,7 +55,8 @@ discard block |
||
55 | 55 | { |
56 | 56 | $name ??= $this->default; |
57 | 57 | |
58 | - if (!isset($this->buckets[$name])) { |
|
58 | + if (!isset($this->buckets[$name])) |
|
59 | + { |
|
59 | 60 | throw new InvalidArgumentException(\sprintf(self::ERROR_NOT_FOUND, $name)); |
60 | 61 | } |
61 | 62 | |
@@ -71,7 +72,8 @@ discard block |
||
71 | 72 | |
72 | 73 | public function add(string $name, BucketInterface $storage, bool $overwrite = false): void |
73 | 74 | { |
74 | - if (!$overwrite && isset($this->buckets[$name])) { |
|
75 | + if (!$overwrite && isset($this->buckets[$name])) |
|
76 | + { |
|
75 | 77 | throw new \InvalidArgumentException(\sprintf(self::ERROR_REDEFINITION, $name)); |
76 | 78 | } |
77 | 79 | |
@@ -97,16 +99,19 @@ discard block |
||
97 | 99 | $uri = $this->uriToString($uri); |
98 | 100 | $result = \parse_url($uri); |
99 | 101 | |
100 | - if ($result === false) { |
|
102 | + if ($result === false) |
|
103 | + { |
|
101 | 104 | $message = 'URI argument must be a valid URI in "[STORAGE]://[PATH_TO_FILE]" format, but `%s` given'; |
102 | 105 | throw new InvalidArgumentException(\sprintf($message, $uri)); |
103 | 106 | } |
104 | 107 | |
105 | - if (!isset($result['scheme'])) { |
|
108 | + if (!isset($result['scheme'])) |
|
109 | + { |
|
106 | 110 | $result['scheme'] = $withScheme ? $this->default : null; |
107 | 111 | } |
108 | 112 | |
109 | - if (!isset($result['host'])) { |
|
113 | + if (!isset($result['host'])) |
|
114 | + { |
|
110 | 115 | $result['host'] = ''; |
111 | 116 | } |
112 | 117 |
@@ -18,21 +18,21 @@ discard block |
||
18 | 18 | */ |
19 | 19 | abstract public function bucket(string $name = null): BucketInterface; |
20 | 20 | |
21 | - public function getContents(string|\Stringable $id): string |
|
21 | + public function getContents(string | \Stringable $id): string |
|
22 | 22 | { |
23 | 23 | [$name, $pathname] = $this->parseUri($id); |
24 | 24 | |
25 | 25 | return $this->bucket($name)->getContents($pathname); |
26 | 26 | } |
27 | 27 | |
28 | - public function getStream(string|\Stringable $id) |
|
28 | + public function getStream(string | \Stringable $id) |
|
29 | 29 | { |
30 | 30 | [$name, $pathname] = $this->parseUri($id); |
31 | 31 | |
32 | 32 | return $this->bucket($name)->getStream($pathname); |
33 | 33 | } |
34 | 34 | |
35 | - public function exists(string|\Stringable $id): bool |
|
35 | + public function exists(string | \Stringable $id): bool |
|
36 | 36 | { |
37 | 37 | [$name, $pathname] = $this->parseUri($id); |
38 | 38 | |
@@ -42,7 +42,7 @@ discard block |
||
42 | 42 | /** |
43 | 43 | * @return positive-int|0 |
44 | 44 | */ |
45 | - public function getLastModified(string|\Stringable $id): int |
|
45 | + public function getLastModified(string | \Stringable $id): int |
|
46 | 46 | { |
47 | 47 | [$name, $pathname] = $this->parseUri($id); |
48 | 48 | |
@@ -52,14 +52,14 @@ discard block |
||
52 | 52 | /** |
53 | 53 | * @return positive-int|0 |
54 | 54 | */ |
55 | - public function getSize(string|\Stringable $id): int |
|
55 | + public function getSize(string | \Stringable $id): int |
|
56 | 56 | { |
57 | 57 | [$name, $pathname] = $this->parseUri($id); |
58 | 58 | |
59 | 59 | return $this->bucket($name)->getSize($pathname); |
60 | 60 | } |
61 | 61 | |
62 | - public function getMimeType(string|\Stringable $id): string |
|
62 | + public function getMimeType(string | \Stringable $id): string |
|
63 | 63 | { |
64 | 64 | [$name, $pathname] = $this->parseUri($id); |
65 | 65 | |
@@ -70,7 +70,7 @@ discard block |
||
70 | 70 | * @return Visibility::VISIBILITY_* |
71 | 71 | */ |
72 | 72 | #[ExpectedValues(valuesFromClass: Visibility::class)] |
73 | - public function getVisibility(string|\Stringable $id): string |
|
73 | + public function getVisibility(string | \Stringable $id): string |
|
74 | 74 | { |
75 | 75 | [$name, $pathname] = $this->parseUri($id); |
76 | 76 | |
@@ -80,5 +80,5 @@ discard block |
||
80 | 80 | /** |
81 | 81 | * {@see Storage::parseUri()} |
82 | 82 | */ |
83 | - abstract protected function parseUri(string|\Stringable $uri, bool $withScheme = true): array; |
|
83 | + abstract protected function parseUri(string | \Stringable $uri, bool $withScheme = true): array; |
|
84 | 84 | } |
@@ -25,7 +25,7 @@ discard block |
||
25 | 25 | * @throws FileOperationException |
26 | 26 | * @throws InvalidArgumentException |
27 | 27 | */ |
28 | - public function create(string|\Stringable $id, array $config = []): FileInterface; |
|
28 | + public function create(string | \Stringable $id, array $config = []): FileInterface; |
|
29 | 29 | |
30 | 30 | /** |
31 | 31 | * {@see BucketInterface::write()} |
@@ -34,7 +34,7 @@ discard block |
||
34 | 34 | * @throws FileOperationException |
35 | 35 | * @throws InvalidArgumentException |
36 | 36 | */ |
37 | - public function write(string|\Stringable $id, mixed $content, array $config = []): FileInterface; |
|
37 | + public function write(string | \Stringable $id, mixed $content, array $config = []): FileInterface; |
|
38 | 38 | |
39 | 39 | /** |
40 | 40 | * {@see BucketInterface::setVisibility()} |
@@ -44,7 +44,7 @@ discard block |
||
44 | 44 | * @throws InvalidArgumentException |
45 | 45 | */ |
46 | 46 | public function setVisibility( |
47 | - string|\Stringable $id, |
|
47 | + string | \Stringable $id, |
|
48 | 48 | #[ExpectedValues(valuesFromClass: Visibility::class)] |
49 | 49 | string $visibility |
50 | 50 | ): FileInterface; |
@@ -56,8 +56,8 @@ discard block |
||
56 | 56 | * @throws InvalidArgumentException |
57 | 57 | */ |
58 | 58 | public function copy( |
59 | - string|\Stringable $source, |
|
60 | - string|\Stringable $destination, |
|
59 | + string | \Stringable $source, |
|
60 | + string | \Stringable $destination, |
|
61 | 61 | array $config = [] |
62 | 62 | ): FileInterface; |
63 | 63 | |
@@ -68,8 +68,8 @@ discard block |
||
68 | 68 | * @throws InvalidArgumentException |
69 | 69 | */ |
70 | 70 | public function move( |
71 | - string|\Stringable $source, |
|
72 | - string|\Stringable $destination, |
|
71 | + string | \Stringable $source, |
|
72 | + string | \Stringable $destination, |
|
73 | 73 | array $config = [] |
74 | 74 | ): FileInterface; |
75 | 75 | |
@@ -79,5 +79,5 @@ discard block |
||
79 | 79 | * @throws FileOperationException |
80 | 80 | * @throws InvalidArgumentException |
81 | 81 | */ |
82 | - public function delete(string|\Stringable $id, bool $clean = false): void; |
|
82 | + public function delete(string | \Stringable $id, bool $clean = false): void; |
|
83 | 83 | } |
@@ -23,7 +23,7 @@ discard block |
||
23 | 23 | * @throws FileOperationException |
24 | 24 | * @throws InvalidArgumentException |
25 | 25 | */ |
26 | - public function getContents(string|\Stringable $id): string; |
|
26 | + public function getContents(string | \Stringable $id): string; |
|
27 | 27 | |
28 | 28 | /** |
29 | 29 | * {@see BucketInterface::getStream()} |
@@ -32,7 +32,7 @@ discard block |
||
32 | 32 | * @throws FileOperationException |
33 | 33 | * @throws InvalidArgumentException |
34 | 34 | */ |
35 | - public function getStream(string|\Stringable $id); |
|
35 | + public function getStream(string | \Stringable $id); |
|
36 | 36 | |
37 | 37 | /** |
38 | 38 | * {@see BucketInterface::exists()} |
@@ -40,7 +40,7 @@ discard block |
||
40 | 40 | * @throws FileOperationException |
41 | 41 | * @throws InvalidArgumentException |
42 | 42 | */ |
43 | - public function exists(string|\Stringable $id): bool; |
|
43 | + public function exists(string | \Stringable $id): bool; |
|
44 | 44 | |
45 | 45 | /** |
46 | 46 | * {@see BucketInterface::getLastModified()} |
@@ -49,7 +49,7 @@ discard block |
||
49 | 49 | * @throws FileOperationException |
50 | 50 | * @throws InvalidArgumentException |
51 | 51 | */ |
52 | - public function getLastModified(string|\Stringable $id): int; |
|
52 | + public function getLastModified(string | \Stringable $id): int; |
|
53 | 53 | |
54 | 54 | /** |
55 | 55 | * {@see BucketInterface::getSize()} |
@@ -58,7 +58,7 @@ discard block |
||
58 | 58 | * @throws FileOperationException |
59 | 59 | * @throws InvalidArgumentException |
60 | 60 | */ |
61 | - public function getSize(string|\Stringable $id): int; |
|
61 | + public function getSize(string | \Stringable $id): int; |
|
62 | 62 | |
63 | 63 | /** |
64 | 64 | *{@see BucketInterface::getMimeType()} |
@@ -66,7 +66,7 @@ discard block |
||
66 | 66 | * @throws FileOperationException |
67 | 67 | * @throws InvalidArgumentException |
68 | 68 | */ |
69 | - public function getMimeType(string|\Stringable $id): string; |
|
69 | + public function getMimeType(string | \Stringable $id): string; |
|
70 | 70 | |
71 | 71 | /** |
72 | 72 | * {@see BucketInterface::getVisibility()} |
@@ -76,5 +76,5 @@ discard block |
||
76 | 76 | * @throws InvalidArgumentException |
77 | 77 | */ |
78 | 78 | #[ExpectedValues(valuesFromClass: Visibility::class)] |
79 | - public function getVisibility(string|\Stringable $id): string; |
|
79 | + public function getVisibility(string | \Stringable $id): string; |
|
80 | 80 | } |
@@ -19,14 +19,14 @@ discard block |
||
19 | 19 | */ |
20 | 20 | abstract public function bucket(string $name = null): BucketInterface; |
21 | 21 | |
22 | - public function create(string|\Stringable $id, array $config = []): FileInterface |
|
22 | + public function create(string | \Stringable $id, array $config = []): FileInterface |
|
23 | 23 | { |
24 | 24 | [$name, $pathname] = $this->parseUri($id); |
25 | 25 | |
26 | 26 | return $this->bucket($name)->create($pathname, $config); |
27 | 27 | } |
28 | 28 | |
29 | - public function write(string|\Stringable $id, mixed $content, array $config = []): FileInterface |
|
29 | + public function write(string | \Stringable $id, mixed $content, array $config = []): FileInterface |
|
30 | 30 | { |
31 | 31 | [$name, $pathname] = $this->parseUri($id); |
32 | 32 | |
@@ -34,7 +34,7 @@ discard block |
||
34 | 34 | } |
35 | 35 | |
36 | 36 | public function setVisibility( |
37 | - string|\Stringable $id, |
|
37 | + string | \Stringable $id, |
|
38 | 38 | #[ExpectedValues(valuesFromClass: Visibility::class)] |
39 | 39 | string $visibility |
40 | 40 | ): FileInterface { |
@@ -44,8 +44,8 @@ discard block |
||
44 | 44 | } |
45 | 45 | |
46 | 46 | public function copy( |
47 | - string|\Stringable $source, |
|
48 | - string|\Stringable $destination, |
|
47 | + string | \Stringable $source, |
|
48 | + string | \Stringable $destination, |
|
49 | 49 | array $config = [] |
50 | 50 | ): FileInterface { |
51 | 51 | [$sourceName, $sourcePathname] = $this->parseUri($source); |
@@ -58,8 +58,8 @@ discard block |
||
58 | 58 | } |
59 | 59 | |
60 | 60 | public function move( |
61 | - string|\Stringable $source, |
|
62 | - string|\Stringable $destination, |
|
61 | + string | \Stringable $source, |
|
62 | + string | \Stringable $destination, |
|
63 | 63 | array $config = [] |
64 | 64 | ): FileInterface { |
65 | 65 | [$sourceName, $sourcePathname] = $this->parseUri($source); |
@@ -71,7 +71,7 @@ discard block |
||
71 | 71 | return $sourceStorage->move($sourcePathname, $destPathname, $destStorage, $config); |
72 | 72 | } |
73 | 73 | |
74 | - public function delete(string|\Stringable $id, bool $clean = false): void |
|
74 | + public function delete(string | \Stringable $id, bool $clean = false): void |
|
75 | 75 | { |
76 | 76 | [$name, $pathname] = $this->parseUri($id); |
77 | 77 | |
@@ -83,5 +83,5 @@ discard block |
||
83 | 83 | /** |
84 | 84 | * {@see Storage::parseUri()} |
85 | 85 | */ |
86 | - abstract protected function parseUri(string|\Stringable $uri, bool $withScheme = true): array; |
|
86 | + abstract protected function parseUri(string | \Stringable $uri, bool $withScheme = true): array; |
|
87 | 87 | } |
@@ -30,7 +30,7 @@ discard block |
||
30 | 30 | |
31 | 31 | public function __construct( |
32 | 32 | private readonly ConfiguratorInterface $config |
33 | - ) { |
|
33 | + ){ |
|
34 | 34 | } |
35 | 35 | |
36 | 36 | public function init(BinderInterface $binder, EnvironmentInterface $env): void |
@@ -45,18 +45,18 @@ discard block |
||
45 | 45 | BucketFactoryInterface $bucketFactory, |
46 | 46 | StorageConfig $config, |
47 | 47 | FactoryInterface $factory |
48 | - ) { |
|
48 | + ){ |
|
49 | 49 | $manager = new Storage($config->getDefaultBucket()); |
50 | 50 | |
51 | 51 | $distributions = $config->getDistributions(); |
52 | 52 | |
53 | - foreach ($config->getAdapters() as $name => $adapter) { |
|
53 | + foreach ($config->getAdapters() as $name => $adapter){ |
|
54 | 54 | $resolver = null; |
55 | 55 | |
56 | - if (isset($distributions[$name])) { |
|
57 | - try { |
|
56 | + if (isset($distributions[$name])){ |
|
57 | + try{ |
|
58 | 58 | $cdn = $factory->make(CdnInterface::class); |
59 | - } catch (NotFoundException $e) { |
|
59 | + }catch (NotFoundException $e){ |
|
60 | 60 | $message = 'Unable to create distribution for bucket "%s". ' |
61 | 61 | . 'Please make sure that bootloader %s is added in your application'; |
62 | 62 | $message = \sprintf($message, $name, DistributionBootloader::class); |
@@ -50,13 +50,18 @@ |
||
50 | 50 | |
51 | 51 | $distributions = $config->getDistributions(); |
52 | 52 | |
53 | - foreach ($config->getAdapters() as $name => $adapter) { |
|
53 | + foreach ($config->getAdapters() as $name => $adapter) |
|
54 | + { |
|
54 | 55 | $resolver = null; |
55 | 56 | |
56 | - if (isset($distributions[$name])) { |
|
57 | - try { |
|
57 | + if (isset($distributions[$name])) |
|
58 | + { |
|
59 | + try |
|
60 | + { |
|
58 | 61 | $cdn = $factory->make(CdnInterface::class); |
59 | - } catch (NotFoundException $e) { |
|
62 | + } |
|
63 | + catch (NotFoundException $e) |
|
64 | + { |
|
60 | 65 | $message = 'Unable to create distribution for bucket "%s". ' |
61 | 66 | . 'Please make sure that bootloader %s is added in your application'; |
62 | 67 | $message = \sprintf($message, $name, DistributionBootloader::class); |