@@ -77,7 +77,7 @@ discard block |
||
77 | 77 | { |
78 | 78 | $name = $name ?? $this->default; |
79 | 79 | |
80 | - if (!isset($this->storages[$name])) { |
|
80 | + if (!isset($this->storages[$name])){ |
|
81 | 81 | throw new InvalidArgumentException(\sprintf(self::ERROR_NOT_FOUND, $name)); |
82 | 82 | } |
83 | 83 | |
@@ -89,7 +89,7 @@ discard block |
||
89 | 89 | */ |
90 | 90 | public function add(string $name, StorageInterface $storage, bool $overwrite = false): void |
91 | 91 | { |
92 | - if ($overwrite === false && isset($this->storages[$name])) { |
|
92 | + if ($overwrite === false && isset($this->storages[$name])){ |
|
93 | 93 | throw new \InvalidArgumentException(\sprintf(self::ERROR_REDEFINITION, $name)); |
94 | 94 | } |
95 | 95 | |
@@ -123,22 +123,22 @@ discard block |
||
123 | 123 | $uri = $this->uriToString($uri); |
124 | 124 | $result = \parse_url($uri); |
125 | 125 | |
126 | - if ($result === false) { |
|
126 | + if ($result === false){ |
|
127 | 127 | $message = 'URI argument must be a valid URI in "[STORAGE]://[PATH_TO_FILE]" format, but `%s` given'; |
128 | 128 | throw new InvalidArgumentException(\sprintf($message, $uri)); |
129 | 129 | } |
130 | 130 | |
131 | - if (!isset($result['scheme'])) { |
|
131 | + if (!isset($result['scheme'])){ |
|
132 | 132 | $result['scheme'] = $withScheme ? $this->default : null; |
133 | 133 | } |
134 | 134 | |
135 | - if (!isset($result['host'])) { |
|
135 | + if (!isset($result['host'])){ |
|
136 | 136 | $result['host'] = ''; |
137 | 137 | } |
138 | 138 | |
139 | 139 | return [ |
140 | 140 | $result['scheme'] ?? null, |
141 | - $result['host'] . \rtrim($result['path'] ?? '', '/'), |
|
141 | + $result['host'].\rtrim($result['path'] ?? '', '/'), |
|
142 | 142 | ]; |
143 | 143 | } |
144 | 144 | |
@@ -149,7 +149,7 @@ discard block |
||
149 | 149 | */ |
150 | 150 | private function uriToString($uri): string |
151 | 151 | { |
152 | - switch (true) { |
|
152 | + switch (true){ |
|
153 | 153 | case $uri instanceof UriInterface: |
154 | 154 | case $uri instanceof \Stringable: |
155 | 155 | case \is_object($uri) && \method_exists($uri, '__toString'): |
@@ -77,7 +77,8 @@ discard block |
||
77 | 77 | { |
78 | 78 | $name = $name ?? $this->default; |
79 | 79 | |
80 | - if (!isset($this->storages[$name])) { |
|
80 | + if (!isset($this->storages[$name])) |
|
81 | + { |
|
81 | 82 | throw new InvalidArgumentException(\sprintf(self::ERROR_NOT_FOUND, $name)); |
82 | 83 | } |
83 | 84 | |
@@ -89,7 +90,8 @@ discard block |
||
89 | 90 | */ |
90 | 91 | public function add(string $name, StorageInterface $storage, bool $overwrite = false): void |
91 | 92 | { |
92 | - if ($overwrite === false && isset($this->storages[$name])) { |
|
93 | + if ($overwrite === false && isset($this->storages[$name])) |
|
94 | + { |
|
93 | 95 | throw new \InvalidArgumentException(\sprintf(self::ERROR_REDEFINITION, $name)); |
94 | 96 | } |
95 | 97 | |
@@ -123,16 +125,19 @@ discard block |
||
123 | 125 | $uri = $this->uriToString($uri); |
124 | 126 | $result = \parse_url($uri); |
125 | 127 | |
126 | - if ($result === false) { |
|
128 | + if ($result === false) |
|
129 | + { |
|
127 | 130 | $message = 'URI argument must be a valid URI in "[STORAGE]://[PATH_TO_FILE]" format, but `%s` given'; |
128 | 131 | throw new InvalidArgumentException(\sprintf($message, $uri)); |
129 | 132 | } |
130 | 133 | |
131 | - if (!isset($result['scheme'])) { |
|
134 | + if (!isset($result['scheme'])) |
|
135 | + { |
|
132 | 136 | $result['scheme'] = $withScheme ? $this->default : null; |
133 | 137 | } |
134 | 138 | |
135 | - if (!isset($result['host'])) { |
|
139 | + if (!isset($result['host'])) |
|
140 | + { |
|
136 | 141 | $result['host'] = ''; |
137 | 142 | } |
138 | 143 | |
@@ -149,7 +154,8 @@ discard block |
||
149 | 154 | */ |
150 | 155 | private function uriToString($uri): string |
151 | 156 | { |
152 | - switch (true) { |
|
157 | + switch (true) |
|
158 | + { |
|
153 | 159 | case $uri instanceof UriInterface: |
154 | 160 | case $uri instanceof \Stringable: |
155 | 161 | case \is_object($uri) && \method_exists($uri, '__toString'): |
@@ -31,7 +31,7 @@ |
||
31 | 31 | { |
32 | 32 | $resolver = $this->getResolver(); |
33 | 33 | |
34 | - if ($resolver === null) { |
|
34 | + if ($resolver === null){ |
|
35 | 35 | throw new \LogicException('Can not generate public url: File not accessible by HTTP'); |
36 | 36 | } |
37 | 37 |
@@ -31,7 +31,8 @@ |
||
31 | 31 | { |
32 | 32 | $resolver = $this->getResolver(); |
33 | 33 | |
34 | - if ($resolver === null) { |
|
34 | + if ($resolver === null) |
|
35 | + { |
|
35 | 36 | throw new \LogicException('Can not generate public url: File not accessible by HTTP'); |
36 | 37 | } |
37 | 38 |
@@ -36,7 +36,7 @@ |
||
36 | 36 | */ |
37 | 37 | public function create(array $config = []): FileInterface |
38 | 38 | { |
39 | - if (!$this->exists()) { |
|
39 | + if (!$this->exists()){ |
|
40 | 40 | return $this->write('', $config); |
41 | 41 | } |
42 | 42 |
@@ -36,7 +36,8 @@ |
||
36 | 36 | */ |
37 | 37 | public function create(array $config = []): FileInterface |
38 | 38 | { |
39 | - if (!$this->exists()) { |
|
39 | + if (!$this->exists()) |
|
40 | + { |
|
40 | 41 | return $this->write('', $config); |
41 | 42 | } |
42 | 43 |
@@ -29,9 +29,9 @@ discard block |
||
29 | 29 | { |
30 | 30 | $fs = $this->getOperator(); |
31 | 31 | |
32 | - try { |
|
32 | + try{ |
|
33 | 33 | return $fs->fileExists($pathname); |
34 | - } catch (FilesystemException $e) { |
|
34 | + }catch (FilesystemException $e){ |
|
35 | 35 | throw new FileOperationException($e->getMessage(), (int)$e->getCode(), $e); |
36 | 36 | } |
37 | 37 | } |
@@ -43,9 +43,9 @@ discard block |
||
43 | 43 | { |
44 | 44 | $fs = $this->getOperator(); |
45 | 45 | |
46 | - try { |
|
46 | + try{ |
|
47 | 47 | return $fs->read($pathname); |
48 | - } catch (FilesystemException $e) { |
|
48 | + }catch (FilesystemException $e){ |
|
49 | 49 | throw new FileOperationException($e->getMessage(), (int)$e->getCode(), $e); |
50 | 50 | } |
51 | 51 | } |
@@ -57,9 +57,9 @@ discard block |
||
57 | 57 | { |
58 | 58 | $fs = $this->getOperator(); |
59 | 59 | |
60 | - try { |
|
60 | + try{ |
|
61 | 61 | return $fs->readStream($pathname); |
62 | - } catch (FilesystemException $e) { |
|
62 | + }catch (FilesystemException $e){ |
|
63 | 63 | throw new FileOperationException($e->getMessage(), (int)$e->getCode(), $e); |
64 | 64 | } |
65 | 65 | } |
@@ -71,9 +71,9 @@ discard block |
||
71 | 71 | { |
72 | 72 | $fs = $this->getOperator(); |
73 | 73 | |
74 | - try { |
|
74 | + try{ |
|
75 | 75 | return $fs->lastModified($pathname); |
76 | - } catch (FilesystemException $e) { |
|
76 | + }catch (FilesystemException $e){ |
|
77 | 77 | throw new FileOperationException($e->getMessage(), (int)$e->getCode(), $e); |
78 | 78 | } |
79 | 79 | } |
@@ -85,9 +85,9 @@ discard block |
||
85 | 85 | { |
86 | 86 | $fs = $this->getOperator(); |
87 | 87 | |
88 | - try { |
|
88 | + try{ |
|
89 | 89 | return $fs->fileSize($pathname); |
90 | - } catch (FilesystemException $e) { |
|
90 | + }catch (FilesystemException $e){ |
|
91 | 91 | throw new FileOperationException($e->getMessage(), (int)$e->getCode(), $e); |
92 | 92 | } |
93 | 93 | } |
@@ -99,9 +99,9 @@ discard block |
||
99 | 99 | { |
100 | 100 | $fs = $this->getOperator(); |
101 | 101 | |
102 | - try { |
|
102 | + try{ |
|
103 | 103 | return $fs->mimeType($pathname); |
104 | - } catch (FilesystemException $e) { |
|
104 | + }catch (FilesystemException $e){ |
|
105 | 105 | throw new FileOperationException($e->getMessage(), (int)$e->getCode(), $e); |
106 | 106 | } |
107 | 107 | } |
@@ -114,11 +114,11 @@ discard block |
||
114 | 114 | { |
115 | 115 | $fs = $this->getOperator(); |
116 | 116 | |
117 | - try { |
|
117 | + try{ |
|
118 | 118 | return $this->fromFlysystemVisibility( |
119 | 119 | $fs->visibility($pathname) |
120 | 120 | ); |
121 | - } catch (FilesystemException $e) { |
|
121 | + }catch (FilesystemException $e){ |
|
122 | 122 | throw new FileOperationException($e->getMessage(), (int)$e->getCode(), $e); |
123 | 123 | } |
124 | 124 | } |
@@ -29,9 +29,12 @@ discard block |
||
29 | 29 | { |
30 | 30 | $fs = $this->getOperator(); |
31 | 31 | |
32 | - try { |
|
32 | + try |
|
33 | + { |
|
33 | 34 | return $fs->fileExists($pathname); |
34 | - } catch (FilesystemException $e) { |
|
35 | + } |
|
36 | + catch (FilesystemException $e) |
|
37 | + { |
|
35 | 38 | throw new FileOperationException($e->getMessage(), (int)$e->getCode(), $e); |
36 | 39 | } |
37 | 40 | } |
@@ -43,9 +46,12 @@ discard block |
||
43 | 46 | { |
44 | 47 | $fs = $this->getOperator(); |
45 | 48 | |
46 | - try { |
|
49 | + try |
|
50 | + { |
|
47 | 51 | return $fs->read($pathname); |
48 | - } catch (FilesystemException $e) { |
|
52 | + } |
|
53 | + catch (FilesystemException $e) |
|
54 | + { |
|
49 | 55 | throw new FileOperationException($e->getMessage(), (int)$e->getCode(), $e); |
50 | 56 | } |
51 | 57 | } |
@@ -57,9 +63,12 @@ discard block |
||
57 | 63 | { |
58 | 64 | $fs = $this->getOperator(); |
59 | 65 | |
60 | - try { |
|
66 | + try |
|
67 | + { |
|
61 | 68 | return $fs->readStream($pathname); |
62 | - } catch (FilesystemException $e) { |
|
69 | + } |
|
70 | + catch (FilesystemException $e) |
|
71 | + { |
|
63 | 72 | throw new FileOperationException($e->getMessage(), (int)$e->getCode(), $e); |
64 | 73 | } |
65 | 74 | } |
@@ -71,9 +80,12 @@ discard block |
||
71 | 80 | { |
72 | 81 | $fs = $this->getOperator(); |
73 | 82 | |
74 | - try { |
|
83 | + try |
|
84 | + { |
|
75 | 85 | return $fs->lastModified($pathname); |
76 | - } catch (FilesystemException $e) { |
|
86 | + } |
|
87 | + catch (FilesystemException $e) |
|
88 | + { |
|
77 | 89 | throw new FileOperationException($e->getMessage(), (int)$e->getCode(), $e); |
78 | 90 | } |
79 | 91 | } |
@@ -85,9 +97,12 @@ discard block |
||
85 | 97 | { |
86 | 98 | $fs = $this->getOperator(); |
87 | 99 | |
88 | - try { |
|
100 | + try |
|
101 | + { |
|
89 | 102 | return $fs->fileSize($pathname); |
90 | - } catch (FilesystemException $e) { |
|
103 | + } |
|
104 | + catch (FilesystemException $e) |
|
105 | + { |
|
91 | 106 | throw new FileOperationException($e->getMessage(), (int)$e->getCode(), $e); |
92 | 107 | } |
93 | 108 | } |
@@ -99,9 +114,12 @@ discard block |
||
99 | 114 | { |
100 | 115 | $fs = $this->getOperator(); |
101 | 116 | |
102 | - try { |
|
117 | + try |
|
118 | + { |
|
103 | 119 | return $fs->mimeType($pathname); |
104 | - } catch (FilesystemException $e) { |
|
120 | + } |
|
121 | + catch (FilesystemException $e) |
|
122 | + { |
|
105 | 123 | throw new FileOperationException($e->getMessage(), (int)$e->getCode(), $e); |
106 | 124 | } |
107 | 125 | } |
@@ -114,11 +132,14 @@ discard block |
||
114 | 132 | { |
115 | 133 | $fs = $this->getOperator(); |
116 | 134 | |
117 | - try { |
|
135 | + try |
|
136 | + { |
|
118 | 137 | return $this->fromFlysystemVisibility( |
119 | 138 | $fs->visibility($pathname) |
120 | 139 | ); |
121 | - } catch (FilesystemException $e) { |
|
140 | + } |
|
141 | + catch (FilesystemException $e) |
|
142 | + { |
|
122 | 143 | throw new FileOperationException($e->getMessage(), (int)$e->getCode(), $e); |
123 | 144 | } |
124 | 145 | } |
@@ -136,7 +136,7 @@ |
||
136 | 136 | #[ExpectedValues(valuesFromClass: \League\Flysystem\Visibility::class)] |
137 | 137 | string $visibility |
138 | 138 | ): string { |
139 | - return $visibility === \League\Flysystem\Visibility::PUBLIC |
|
139 | + return $visibility === \League\Flysystem\Visibility::public |
|
140 | 140 | ? Visibility::VISIBILITY_PUBLIC |
141 | 141 | : Visibility::VISIBILITY_PRIVATE; |
142 | 142 | } |
@@ -41,8 +41,8 @@ discard block |
||
41 | 41 | |
42 | 42 | $fs = $this->getOperator(); |
43 | 43 | |
44 | - try { |
|
45 | - switch (true) { |
|
44 | + try{ |
|
45 | + switch (true){ |
|
46 | 46 | case \is_object($content): |
47 | 47 | case \is_string($content): |
48 | 48 | $fs->write($pathname, (string)$content, $config); |
@@ -56,7 +56,7 @@ discard block |
||
56 | 56 | $message = 'Content must be a resource stream or stringable type, but %s passed'; |
57 | 57 | throw new \InvalidArgumentException(\sprintf($message, \get_debug_type($content))); |
58 | 58 | } |
59 | - } catch (FilesystemException $e) { |
|
59 | + }catch (FilesystemException $e){ |
|
60 | 60 | throw new FileOperationException($e->getMessage(), (int)$e->getCode(), $e); |
61 | 61 | } |
62 | 62 | |
@@ -73,9 +73,9 @@ discard block |
||
73 | 73 | ): FileInterface { |
74 | 74 | $fs = $this->getOperator(); |
75 | 75 | |
76 | - try { |
|
76 | + try{ |
|
77 | 77 | $fs->setVisibility($pathname, $this->toFlysystemVisibility($visibility)); |
78 | - } catch (FilesystemException $e) { |
|
78 | + }catch (FilesystemException $e){ |
|
79 | 79 | throw new FileOperationException($e->getMessage(), (int)$e->getCode(), $e); |
80 | 80 | } |
81 | 81 | |
@@ -93,10 +93,10 @@ discard block |
||
93 | 93 | ): FileInterface { |
94 | 94 | $fs = $this->getOperator(); |
95 | 95 | |
96 | - if ($storage === null || $storage === $this) { |
|
97 | - try { |
|
96 | + if ($storage === null || $storage === $this){ |
|
97 | + try{ |
|
98 | 98 | $fs->copy($source, $destination, $config); |
99 | - } catch (FilesystemException $e) { |
|
99 | + }catch (FilesystemException $e){ |
|
100 | 100 | throw new FileOperationException($e->getMessage(), (int)$e->getCode(), $e); |
101 | 101 | } |
102 | 102 | |
@@ -117,10 +117,10 @@ discard block |
||
117 | 117 | ): FileInterface { |
118 | 118 | $fs = $this->getOperator(); |
119 | 119 | |
120 | - if ($storage === null || $storage === $this) { |
|
121 | - try { |
|
120 | + if ($storage === null || $storage === $this){ |
|
121 | + try{ |
|
122 | 122 | $fs->move($source, $destination, $config); |
123 | - } catch (FilesystemException $e) { |
|
123 | + }catch (FilesystemException $e){ |
|
124 | 124 | throw new FileOperationException($e->getMessage(), (int)$e->getCode(), $e); |
125 | 125 | } |
126 | 126 | |
@@ -141,13 +141,13 @@ discard block |
||
141 | 141 | { |
142 | 142 | $fs = $this->getOperator(); |
143 | 143 | |
144 | - try { |
|
144 | + try{ |
|
145 | 145 | $fs->delete($pathname); |
146 | 146 | |
147 | - if ($clean) { |
|
147 | + if ($clean){ |
|
148 | 148 | $this->deleteEmptyDirectories($this->getParentDirectory($pathname)); |
149 | 149 | } |
150 | - } catch (FilesystemException $e) { |
|
150 | + }catch (FilesystemException $e){ |
|
151 | 151 | throw new FileOperationException($e->getMessage(), (int)$e->getCode(), $e); |
152 | 152 | } |
153 | 153 | } |
@@ -215,19 +215,19 @@ discard block |
||
215 | 215 | */ |
216 | 216 | private function deleteEmptyDirectories(string $directory): void |
217 | 217 | { |
218 | - if (!$this->hasParentDirectory($directory)) { |
|
218 | + if (!$this->hasParentDirectory($directory)){ |
|
219 | 219 | return; |
220 | 220 | } |
221 | 221 | |
222 | 222 | $fs = $this->getOperator(); |
223 | 223 | |
224 | - try { |
|
225 | - if (!$this->hasFiles($directory)) { |
|
224 | + try{ |
|
225 | + if (!$this->hasFiles($directory)){ |
|
226 | 226 | $fs->deleteDirectory($directory); |
227 | 227 | |
228 | 228 | $this->deleteEmptyDirectories($this->getParentDirectory($directory)); |
229 | 229 | } |
230 | - } catch (FilesystemException $e) { |
|
230 | + }catch (FilesystemException $e){ |
|
231 | 231 | throw new FileOperationException($e->getMessage(), (int)$e->getCode(), $e); |
232 | 232 | } |
233 | 233 | } |
@@ -250,7 +250,7 @@ discard block |
||
250 | 250 | { |
251 | 251 | $fs = $this->getOperator(); |
252 | 252 | |
253 | - foreach ($fs->listContents($directory) as $_) { |
|
253 | + foreach ($fs->listContents($directory) as $_){ |
|
254 | 254 | return true; |
255 | 255 | } |
256 | 256 | |
@@ -266,15 +266,15 @@ discard block |
||
266 | 266 | */ |
267 | 267 | private function isStringable($value): bool |
268 | 268 | { |
269 | - if (\is_string($value)) { |
|
269 | + if (\is_string($value)){ |
|
270 | 270 | return true; |
271 | 271 | } |
272 | 272 | |
273 | - if (!\is_object($value)) { |
|
273 | + if (!\is_object($value)){ |
|
274 | 274 | return false; |
275 | 275 | } |
276 | 276 | |
277 | - if (\PHP_VERSION_ID >= 80000) { |
|
277 | + if (\PHP_VERSION_ID >= 80000){ |
|
278 | 278 | return $value instanceof \Stringable; |
279 | 279 | } |
280 | 280 |
@@ -41,8 +41,10 @@ discard block |
||
41 | 41 | |
42 | 42 | $fs = $this->getOperator(); |
43 | 43 | |
44 | - try { |
|
45 | - switch (true) { |
|
44 | + try |
|
45 | + { |
|
46 | + switch (true) |
|
47 | + { |
|
46 | 48 | case \is_object($content): |
47 | 49 | case \is_string($content): |
48 | 50 | $fs->write($pathname, (string)$content, $config); |
@@ -56,7 +58,9 @@ discard block |
||
56 | 58 | $message = 'Content must be a resource stream or stringable type, but %s passed'; |
57 | 59 | throw new \InvalidArgumentException(\sprintf($message, \get_debug_type($content))); |
58 | 60 | } |
59 | - } catch (FilesystemException $e) { |
|
61 | + } |
|
62 | + catch (FilesystemException $e) |
|
63 | + { |
|
60 | 64 | throw new FileOperationException($e->getMessage(), (int)$e->getCode(), $e); |
61 | 65 | } |
62 | 66 | |
@@ -73,9 +77,12 @@ discard block |
||
73 | 77 | ): FileInterface { |
74 | 78 | $fs = $this->getOperator(); |
75 | 79 | |
76 | - try { |
|
80 | + try |
|
81 | + { |
|
77 | 82 | $fs->setVisibility($pathname, $this->toFlysystemVisibility($visibility)); |
78 | - } catch (FilesystemException $e) { |
|
83 | + } |
|
84 | + catch (FilesystemException $e) |
|
85 | + { |
|
79 | 86 | throw new FileOperationException($e->getMessage(), (int)$e->getCode(), $e); |
80 | 87 | } |
81 | 88 | |
@@ -93,10 +100,14 @@ discard block |
||
93 | 100 | ): FileInterface { |
94 | 101 | $fs = $this->getOperator(); |
95 | 102 | |
96 | - if ($storage === null || $storage === $this) { |
|
97 | - try { |
|
103 | + if ($storage === null || $storage === $this) |
|
104 | + { |
|
105 | + try |
|
106 | + { |
|
98 | 107 | $fs->copy($source, $destination, $config); |
99 | - } catch (FilesystemException $e) { |
|
108 | + } |
|
109 | + catch (FilesystemException $e) |
|
110 | + { |
|
100 | 111 | throw new FileOperationException($e->getMessage(), (int)$e->getCode(), $e); |
101 | 112 | } |
102 | 113 | |
@@ -117,10 +128,14 @@ discard block |
||
117 | 128 | ): FileInterface { |
118 | 129 | $fs = $this->getOperator(); |
119 | 130 | |
120 | - if ($storage === null || $storage === $this) { |
|
121 | - try { |
|
131 | + if ($storage === null || $storage === $this) |
|
132 | + { |
|
133 | + try |
|
134 | + { |
|
122 | 135 | $fs->move($source, $destination, $config); |
123 | - } catch (FilesystemException $e) { |
|
136 | + } |
|
137 | + catch (FilesystemException $e) |
|
138 | + { |
|
124 | 139 | throw new FileOperationException($e->getMessage(), (int)$e->getCode(), $e); |
125 | 140 | } |
126 | 141 | |
@@ -141,13 +156,17 @@ discard block |
||
141 | 156 | { |
142 | 157 | $fs = $this->getOperator(); |
143 | 158 | |
144 | - try { |
|
159 | + try |
|
160 | + { |
|
145 | 161 | $fs->delete($pathname); |
146 | 162 | |
147 | - if ($clean) { |
|
163 | + if ($clean) |
|
164 | + { |
|
148 | 165 | $this->deleteEmptyDirectories($this->getParentDirectory($pathname)); |
149 | 166 | } |
150 | - } catch (FilesystemException $e) { |
|
167 | + } |
|
168 | + catch (FilesystemException $e) |
|
169 | + { |
|
151 | 170 | throw new FileOperationException($e->getMessage(), (int)$e->getCode(), $e); |
152 | 171 | } |
153 | 172 | } |
@@ -215,19 +234,24 @@ discard block |
||
215 | 234 | */ |
216 | 235 | private function deleteEmptyDirectories(string $directory): void |
217 | 236 | { |
218 | - if (!$this->hasParentDirectory($directory)) { |
|
237 | + if (!$this->hasParentDirectory($directory)) |
|
238 | + { |
|
219 | 239 | return; |
220 | 240 | } |
221 | 241 | |
222 | 242 | $fs = $this->getOperator(); |
223 | 243 | |
224 | - try { |
|
225 | - if (!$this->hasFiles($directory)) { |
|
244 | + try |
|
245 | + { |
|
246 | + if (!$this->hasFiles($directory)) |
|
247 | + { |
|
226 | 248 | $fs->deleteDirectory($directory); |
227 | 249 | |
228 | 250 | $this->deleteEmptyDirectories($this->getParentDirectory($directory)); |
229 | 251 | } |
230 | - } catch (FilesystemException $e) { |
|
252 | + } |
|
253 | + catch (FilesystemException $e) |
|
254 | + { |
|
231 | 255 | throw new FileOperationException($e->getMessage(), (int)$e->getCode(), $e); |
232 | 256 | } |
233 | 257 | } |
@@ -250,7 +274,8 @@ discard block |
||
250 | 274 | { |
251 | 275 | $fs = $this->getOperator(); |
252 | 276 | |
253 | - foreach ($fs->listContents($directory) as $_) { |
|
277 | + foreach ($fs->listContents($directory) as $_) |
|
278 | + { |
|
254 | 279 | return true; |
255 | 280 | } |
256 | 281 | |
@@ -266,15 +291,18 @@ discard block |
||
266 | 291 | */ |
267 | 292 | private function isStringable($value): bool |
268 | 293 | { |
269 | - if (\is_string($value)) { |
|
294 | + if (\is_string($value)) |
|
295 | + { |
|
270 | 296 | return true; |
271 | 297 | } |
272 | 298 | |
273 | - if (!\is_object($value)) { |
|
299 | + if (!\is_object($value)) |
|
300 | + { |
|
274 | 301 | return false; |
275 | 302 | } |
276 | 303 | |
277 | - if (\PHP_VERSION_ID >= 80000) { |
|
304 | + if (\PHP_VERSION_ID >= 80000) |
|
305 | + { |
|
278 | 306 | return $value instanceof \Stringable; |
279 | 307 | } |
280 | 308 |
@@ -166,8 +166,8 @@ |
||
166 | 166 | string $visibility |
167 | 167 | ): string { |
168 | 168 | return ($visibility === Visibility::VISIBILITY_PUBLIC) |
169 | - ? \League\Flysystem\Visibility::PUBLIC |
|
170 | - : \League\Flysystem\Visibility::PRIVATE; |
|
169 | + ? \League\Flysystem\Visibility::public |
|
170 | + : \League\Flysystem\Visibility::private; |
|
171 | 171 | } |
172 | 172 | |
173 | 173 | /** |
@@ -14,7 +14,7 @@ discard block |
||
14 | 14 | /** |
15 | 15 | * @var string |
16 | 16 | */ |
17 | - protected const LOCAL_STORAGE_DIRECTORY = __DIR__ . '/storage'; |
|
17 | + protected const LOCAL_STORAGE_DIRECTORY = __DIR__.'/storage'; |
|
18 | 18 | |
19 | 19 | /** |
20 | 20 | * @var StorageInterface |
@@ -38,7 +38,7 @@ discard block |
||
38 | 38 | ); |
39 | 39 | |
40 | 40 | $this->second = Storage::fromAdapter( |
41 | - new LocalFilesystemAdapter(self::LOCAL_STORAGE_DIRECTORY . '/second') |
|
41 | + new LocalFilesystemAdapter(self::LOCAL_STORAGE_DIRECTORY.'/second') |
|
42 | 42 | ); |
43 | 43 | } |
44 | 44 | |
@@ -63,22 +63,22 @@ discard block |
||
63 | 63 | ); |
64 | 64 | |
65 | 65 | /** @var \SplFileInfo $file */ |
66 | - foreach($iterator as $file) { |
|
67 | - if ($file->getFilename() === '.gitignore') { |
|
66 | + foreach ($iterator as $file){ |
|
67 | + if ($file->getFilename() === '.gitignore'){ |
|
68 | 68 | continue; |
69 | 69 | } |
70 | 70 | |
71 | 71 | \error_clear_last(); |
72 | 72 | |
73 | - if ($file->isDir()) { |
|
73 | + if ($file->isDir()){ |
|
74 | 74 | @\rmdir($file->getPathname()); |
75 | - } else { |
|
75 | + }else{ |
|
76 | 76 | @\unlink($file->getPathname()); |
77 | 77 | } |
78 | 78 | |
79 | - if ($error = \error_get_last()) { |
|
79 | + if ($error = \error_get_last()){ |
|
80 | 80 | $prefix = 'An error occurred while clear temporary local storage directory: '; |
81 | - $this->addWarning($prefix . $error['message']); |
|
81 | + $this->addWarning($prefix.$error['message']); |
|
82 | 82 | } |
83 | 83 | } |
84 | 84 | } |
@@ -63,20 +63,26 @@ |
||
63 | 63 | ); |
64 | 64 | |
65 | 65 | /** @var \SplFileInfo $file */ |
66 | - foreach($iterator as $file) { |
|
67 | - if ($file->getFilename() === '.gitignore') { |
|
66 | + foreach($iterator as $file) |
|
67 | + { |
|
68 | + if ($file->getFilename() === '.gitignore') |
|
69 | + { |
|
68 | 70 | continue; |
69 | 71 | } |
70 | 72 | |
71 | 73 | \error_clear_last(); |
72 | 74 | |
73 | - if ($file->isDir()) { |
|
75 | + if ($file->isDir()) |
|
76 | + { |
|
74 | 77 | @\rmdir($file->getPathname()); |
75 | - } else { |
|
78 | + } |
|
79 | + else |
|
80 | + { |
|
76 | 81 | @\unlink($file->getPathname()); |
77 | 82 | } |
78 | 83 | |
79 | - if ($error = \error_get_last()) { |
|
84 | + if ($error = \error_get_last()) |
|
85 | + { |
|
80 | 86 | $prefix = 'An error occurred while clear temporary local storage directory: '; |
81 | 87 | $this->addWarning($prefix . $error['message']); |
82 | 88 | } |
@@ -57,8 +57,8 @@ discard block |
||
57 | 57 | public function testVisibility(): void |
58 | 58 | { |
59 | 59 | $this->markTestSkipped( |
60 | - 'This test [' . __FUNCTION__ . '] returns incorrect visibility ' . |
|
61 | - 'of files on Windows OS. ' . |
|
60 | + 'This test ['.__FUNCTION__.'] returns incorrect visibility '. |
|
61 | + 'of files on Windows OS. '. |
|
62 | 62 | 'It is required to understand the situation' |
63 | 63 | ); |
64 | 64 | |
@@ -151,7 +151,7 @@ discard block |
||
151 | 151 | |
152 | 152 | $actual = ''; |
153 | 153 | $stream = $this->local->getStream('file.txt'); |
154 | - while (!\feof($stream)) { |
|
154 | + while (!\feof($stream)){ |
|
155 | 155 | $actual .= \fread($stream, 256); |
156 | 156 | } |
157 | 157 | \fclose($stream); |
@@ -151,7 +151,8 @@ |
||
151 | 151 | |
152 | 152 | $actual = ''; |
153 | 153 | $stream = $this->local->getStream('file.txt'); |
154 | - while (!\feof($stream)) { |
|
154 | + while (!\feof($stream)) |
|
155 | + { |
|
155 | 156 | $actual .= \fread($stream, 256); |
156 | 157 | } |
157 | 158 | \fclose($stream); |
@@ -92,7 +92,7 @@ discard block |
||
92 | 92 | { |
93 | 93 | $this->expectException(InvalidArgumentException::class); |
94 | 94 | $this->expectExceptionMessage( |
95 | - 'URI argument must be a valid URI in ' . |
|
95 | + 'URI argument must be a valid URI in '. |
|
96 | 96 | '"[STORAGE]://[PATH_TO_FILE]" format, but `test://` given' |
97 | 97 | ); |
98 | 98 | |
@@ -157,8 +157,8 @@ discard block |
||
157 | 157 | public function testVisibility(): void |
158 | 158 | { |
159 | 159 | $this->markTestSkipped( |
160 | - 'This test [' . __FUNCTION__ . '] returns incorrect visibility ' . |
|
161 | - 'of files on Windows OS. ' . |
|
160 | + 'This test ['.__FUNCTION__.'] returns incorrect visibility '. |
|
161 | + 'of files on Windows OS. '. |
|
162 | 162 | 'It is required to understand the situation' |
163 | 163 | ); |
164 | 164 | |
@@ -257,7 +257,7 @@ discard block |
||
257 | 257 | |
258 | 258 | $actual = ''; |
259 | 259 | $stream = $this->manager->getStream('file.txt'); |
260 | - while (!\feof($stream)) { |
|
260 | + while (!\feof($stream)){ |
|
261 | 261 | $actual .= \fread($stream, 256); |
262 | 262 | } |
263 | 263 | \fclose($stream); |
@@ -257,7 +257,8 @@ |
||
257 | 257 | |
258 | 258 | $actual = ''; |
259 | 259 | $stream = $this->manager->getStream('file.txt'); |
260 | - while (!\feof($stream)) { |
|
260 | + while (!\feof($stream)) |
|
261 | + { |
|
261 | 262 | $actual .= \fread($stream, 256); |
262 | 263 | } |
263 | 264 | \fclose($stream); |
@@ -81,8 +81,8 @@ discard block |
||
81 | 81 | public function testVisibility(): void |
82 | 82 | { |
83 | 83 | $this->markTestSkipped( |
84 | - 'This test [' . __FUNCTION__ . '] returns incorrect visibility ' . |
|
85 | - 'of files on Windows OS. ' . |
|
84 | + 'This test ['.__FUNCTION__.'] returns incorrect visibility '. |
|
85 | + 'of files on Windows OS. '. |
|
86 | 86 | 'It is required to understand the situation' |
87 | 87 | ); |
88 | 88 | |
@@ -190,7 +190,7 @@ discard block |
||
190 | 190 | |
191 | 191 | $actual = ''; |
192 | 192 | $stream = $source->getStream(); |
193 | - while (!\feof($stream)) { |
|
193 | + while (!\feof($stream)){ |
|
194 | 194 | $actual .= \fread($stream, 256); |
195 | 195 | } |
196 | 196 | \fclose($stream); |
@@ -190,7 +190,8 @@ |
||
190 | 190 | |
191 | 191 | $actual = ''; |
192 | 192 | $stream = $source->getStream(); |
193 | - while (!\feof($stream)) { |
|
193 | + while (!\feof($stream)) |
|
194 | + { |
|
194 | 195 | $actual .= \fread($stream, 256); |
195 | 196 | } |
196 | 197 | \fclose($stream); |