@@ -57,7 +57,7 @@ discard block |
||
57 | 57 | */ |
58 | 58 | public function has(string $domain, string $id): bool |
59 | 59 | { |
60 | - if (!isset($this->data[$domain])) { |
|
60 | + if (!isset($this->data[$domain])){ |
|
61 | 61 | return false; |
62 | 62 | } |
63 | 63 | |
@@ -69,7 +69,7 @@ discard block |
||
69 | 69 | */ |
70 | 70 | public function get(string $domain, string $id): string |
71 | 71 | { |
72 | - if (!$this->has($domain, $id)) { |
|
72 | + if (!$this->has($domain, $id)){ |
|
73 | 73 | throw new CatalogueException("Undefined string in domain '{$domain}'"); |
74 | 74 | } |
75 | 75 | |
@@ -99,15 +99,15 @@ discard block |
||
99 | 99 | */ |
100 | 100 | public function mergeFrom(MessageCatalogue $catalogue, bool $follow = true): void |
101 | 101 | { |
102 | - foreach ($catalogue->all() as $domain => $messages) { |
|
103 | - if (!isset($this->data[$domain])) { |
|
102 | + foreach ($catalogue->all() as $domain => $messages){ |
|
103 | + if (!isset($this->data[$domain])){ |
|
104 | 104 | $this->data[$domain] = []; |
105 | 105 | } |
106 | 106 | |
107 | - if ($follow) { |
|
107 | + if ($follow){ |
|
108 | 108 | //MessageCatalogue string has higher priority that string stored in memory |
109 | 109 | $this->data[$domain] = array_merge($messages, $this->data[$domain]); |
110 | - } else { |
|
110 | + }else{ |
|
111 | 111 | $this->data[$domain] = array_merge($this->data[$domain], $messages); |
112 | 112 | } |
113 | 113 | } |
@@ -57,7 +57,8 @@ discard block |
||
57 | 57 | */ |
58 | 58 | public function has(string $domain, string $id): bool |
59 | 59 | { |
60 | - if (!isset($this->data[$domain])) { |
|
60 | + if (!isset($this->data[$domain])) |
|
61 | + { |
|
61 | 62 | return false; |
62 | 63 | } |
63 | 64 | |
@@ -69,7 +70,8 @@ discard block |
||
69 | 70 | */ |
70 | 71 | public function get(string $domain, string $id): string |
71 | 72 | { |
72 | - if (!$this->has($domain, $id)) { |
|
73 | + if (!$this->has($domain, $id)) |
|
74 | + { |
|
73 | 75 | throw new CatalogueException("Undefined string in domain '{$domain}'"); |
74 | 76 | } |
75 | 77 | |
@@ -99,15 +101,20 @@ discard block |
||
99 | 101 | */ |
100 | 102 | public function mergeFrom(MessageCatalogue $catalogue, bool $follow = true): void |
101 | 103 | { |
102 | - foreach ($catalogue->all() as $domain => $messages) { |
|
103 | - if (!isset($this->data[$domain])) { |
|
104 | + foreach ($catalogue->all() as $domain => $messages) |
|
105 | + { |
|
106 | + if (!isset($this->data[$domain])) |
|
107 | + { |
|
104 | 108 | $this->data[$domain] = []; |
105 | 109 | } |
106 | 110 | |
107 | - if ($follow) { |
|
111 | + if ($follow) |
|
112 | + { |
|
108 | 113 | //MessageCatalogue string has higher priority that string stored in memory |
109 | 114 | $this->data[$domain] = array_merge($messages, $this->data[$domain]); |
110 | - } else { |
|
115 | + } |
|
116 | + else |
|
117 | + { |
|
111 | 118 | $this->data[$domain] = array_merge($this->data[$domain], $messages); |
112 | 119 | } |
113 | 120 | } |
@@ -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 | } |
@@ -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 BucketInterface |
@@ -38,7 +38,7 @@ discard block |
||
38 | 38 | ); |
39 | 39 | |
40 | 40 | $this->second = Bucket::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 | } |
@@ -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); |
@@ -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); |
@@ -175,7 +175,7 @@ discard block |
||
175 | 175 | */ |
176 | 176 | public function testLastModified(): void |
177 | 177 | { |
178 | - $now = (int) \floor(\microtime(true)); |
|
178 | + $now = (int)\floor(\microtime(true)); |
|
179 | 179 | |
180 | 180 | $this->local->create('file.txt'); |
181 | 181 | $before = $this->local->getLastModified('file.txt'); |
@@ -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); |
@@ -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); |
@@ -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); |
@@ -216,7 +216,7 @@ discard block |
||
216 | 216 | */ |
217 | 217 | public function testLastModified(): void |
218 | 218 | { |
219 | - $now = (int) \floor(\microtime(true)); |
|
219 | + $now = (int)\floor(\microtime(true)); |
|
220 | 220 | |
221 | 221 | $file = $this->local->file('file.txt') |
222 | 222 | ->create() |
@@ -64,7 +64,7 @@ |
||
64 | 64 | { |
65 | 65 | $name = $this->storage->getName(); |
66 | 66 | |
67 | - if ($name === null) { |
|
67 | + if ($name === null){ |
|
68 | 68 | return $this->getPathname(); |
69 | 69 | } |
70 | 70 |
@@ -64,7 +64,8 @@ |
||
64 | 64 | { |
65 | 65 | $name = $this->storage->getName(); |
66 | 66 | |
67 | - if ($name === null) { |
|
67 | + if ($name === null) |
|
68 | + { |
|
68 | 69 | return $this->getPathname(); |
69 | 70 | } |
70 | 71 |
@@ -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 | } |
@@ -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(), $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(), $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(), $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(), $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(), $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(), $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(), $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(), $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(), $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(), $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(), $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(), $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(), $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(), $e->getCode(), $e); |
123 | 144 | } |
124 | 145 | } |
@@ -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 | /** |
@@ -31,7 +31,7 @@ discard block |
||
31 | 31 | */ |
32 | 32 | public function create(string $pathname, array $config = []): FileInterface |
33 | 33 | { |
34 | - if ($this instanceof ReadableInterface && !$this->exists($pathname)) { |
|
34 | + if ($this instanceof ReadableInterface && !$this->exists($pathname)){ |
|
35 | 35 | return $this->write($pathname, '', $config); |
36 | 36 | } |
37 | 37 | |
@@ -47,8 +47,8 @@ discard block |
||
47 | 47 | |
48 | 48 | $fs = $this->getOperator(); |
49 | 49 | |
50 | - try { |
|
51 | - switch (true) { |
|
50 | + try{ |
|
51 | + switch (true){ |
|
52 | 52 | case \is_object($content): |
53 | 53 | case \is_string($content): |
54 | 54 | $fs->write($pathname, (string)$content, $config); |
@@ -62,7 +62,7 @@ discard block |
||
62 | 62 | $message = 'Content must be a resource stream or stringable type, but %s passed'; |
63 | 63 | throw new InvalidArgumentException(\sprintf($message, \get_debug_type($content))); |
64 | 64 | } |
65 | - } catch (FilesystemException $e) { |
|
65 | + }catch (FilesystemException $e){ |
|
66 | 66 | throw new FileOperationException($e->getMessage(), $e->getCode(), $e); |
67 | 67 | } |
68 | 68 | |
@@ -79,9 +79,9 @@ discard block |
||
79 | 79 | ): FileInterface { |
80 | 80 | $fs = $this->getOperator(); |
81 | 81 | |
82 | - try { |
|
82 | + try{ |
|
83 | 83 | $fs->setVisibility($pathname, $this->toFlysystemVisibility($visibility)); |
84 | - } catch (FilesystemException $e) { |
|
84 | + }catch (FilesystemException $e){ |
|
85 | 85 | throw new FileOperationException($e->getMessage(), $e->getCode(), $e); |
86 | 86 | } |
87 | 87 | |
@@ -99,10 +99,10 @@ discard block |
||
99 | 99 | ): FileInterface { |
100 | 100 | $fs = $this->getOperator(); |
101 | 101 | |
102 | - if ($storage === null || $storage === $this) { |
|
103 | - try { |
|
102 | + if ($storage === null || $storage === $this){ |
|
103 | + try{ |
|
104 | 104 | $fs->copy($source, $destination, $config); |
105 | - } catch (FilesystemException $e) { |
|
105 | + }catch (FilesystemException $e){ |
|
106 | 106 | throw new FileOperationException($e->getMessage(), $e->getCode(), $e); |
107 | 107 | } |
108 | 108 | |
@@ -123,10 +123,10 @@ discard block |
||
123 | 123 | ): FileInterface { |
124 | 124 | $fs = $this->getOperator(); |
125 | 125 | |
126 | - if ($storage === null || $storage === $this) { |
|
127 | - try { |
|
126 | + if ($storage === null || $storage === $this){ |
|
127 | + try{ |
|
128 | 128 | $fs->move($source, $destination, $config); |
129 | - } catch (FilesystemException $e) { |
|
129 | + }catch (FilesystemException $e){ |
|
130 | 130 | throw new FileOperationException($e->getMessage(), $e->getCode(), $e); |
131 | 131 | } |
132 | 132 | |
@@ -147,13 +147,13 @@ discard block |
||
147 | 147 | { |
148 | 148 | $fs = $this->getOperator(); |
149 | 149 | |
150 | - try { |
|
150 | + try{ |
|
151 | 151 | $fs->delete($pathname); |
152 | 152 | |
153 | - if ($clean) { |
|
153 | + if ($clean){ |
|
154 | 154 | $this->deleteEmptyDirectories($this->getParentDirectory($pathname)); |
155 | 155 | } |
156 | - } catch (FilesystemException $e) { |
|
156 | + }catch (FilesystemException $e){ |
|
157 | 157 | throw new FileOperationException($e->getMessage(), $e->getCode(), $e); |
158 | 158 | } |
159 | 159 | } |
@@ -209,19 +209,19 @@ discard block |
||
209 | 209 | */ |
210 | 210 | private function deleteEmptyDirectories(string $directory): void |
211 | 211 | { |
212 | - if (!$this->hasParentDirectory($directory)) { |
|
212 | + if (!$this->hasParentDirectory($directory)){ |
|
213 | 213 | return; |
214 | 214 | } |
215 | 215 | |
216 | 216 | $fs = $this->getOperator(); |
217 | 217 | |
218 | - try { |
|
219 | - if (!$this->hasFiles($directory)) { |
|
218 | + try{ |
|
219 | + if (!$this->hasFiles($directory)){ |
|
220 | 220 | $fs->deleteDirectory($directory); |
221 | 221 | |
222 | 222 | $this->deleteEmptyDirectories($this->getParentDirectory($directory)); |
223 | 223 | } |
224 | - } catch (FilesystemException $e) { |
|
224 | + }catch (FilesystemException $e){ |
|
225 | 225 | throw new FileOperationException($e->getMessage(), $e->getCode(), $e); |
226 | 226 | } |
227 | 227 | } |
@@ -243,7 +243,7 @@ discard block |
||
243 | 243 | { |
244 | 244 | $fs = $this->getOperator(); |
245 | 245 | |
246 | - foreach ($fs->listContents($directory) as $_) { |
|
246 | + foreach ($fs->listContents($directory) as $_){ |
|
247 | 247 | return true; |
248 | 248 | } |
249 | 249 | |
@@ -258,15 +258,15 @@ discard block |
||
258 | 258 | */ |
259 | 259 | private function isStringable($value): bool |
260 | 260 | { |
261 | - if (\is_string($value)) { |
|
261 | + if (\is_string($value)){ |
|
262 | 262 | return true; |
263 | 263 | } |
264 | 264 | |
265 | - if (!\is_object($value)) { |
|
265 | + if (!\is_object($value)){ |
|
266 | 266 | return false; |
267 | 267 | } |
268 | 268 | |
269 | - if (\PHP_VERSION_ID >= 80000) { |
|
269 | + if (\PHP_VERSION_ID >= 80000){ |
|
270 | 270 | return $value instanceof Stringable; |
271 | 271 | } |
272 | 272 |
@@ -31,7 +31,8 @@ discard block |
||
31 | 31 | */ |
32 | 32 | public function create(string $pathname, array $config = []): FileInterface |
33 | 33 | { |
34 | - if ($this instanceof ReadableInterface && !$this->exists($pathname)) { |
|
34 | + if ($this instanceof ReadableInterface && !$this->exists($pathname)) |
|
35 | + { |
|
35 | 36 | return $this->write($pathname, '', $config); |
36 | 37 | } |
37 | 38 | |
@@ -47,8 +48,10 @@ discard block |
||
47 | 48 | |
48 | 49 | $fs = $this->getOperator(); |
49 | 50 | |
50 | - try { |
|
51 | - switch (true) { |
|
51 | + try |
|
52 | + { |
|
53 | + switch (true) |
|
54 | + { |
|
52 | 55 | case \is_object($content): |
53 | 56 | case \is_string($content): |
54 | 57 | $fs->write($pathname, (string)$content, $config); |
@@ -62,7 +65,9 @@ discard block |
||
62 | 65 | $message = 'Content must be a resource stream or stringable type, but %s passed'; |
63 | 66 | throw new InvalidArgumentException(\sprintf($message, \get_debug_type($content))); |
64 | 67 | } |
65 | - } catch (FilesystemException $e) { |
|
68 | + } |
|
69 | + catch (FilesystemException $e) |
|
70 | + { |
|
66 | 71 | throw new FileOperationException($e->getMessage(), $e->getCode(), $e); |
67 | 72 | } |
68 | 73 | |
@@ -79,9 +84,12 @@ discard block |
||
79 | 84 | ): FileInterface { |
80 | 85 | $fs = $this->getOperator(); |
81 | 86 | |
82 | - try { |
|
87 | + try |
|
88 | + { |
|
83 | 89 | $fs->setVisibility($pathname, $this->toFlysystemVisibility($visibility)); |
84 | - } catch (FilesystemException $e) { |
|
90 | + } |
|
91 | + catch (FilesystemException $e) |
|
92 | + { |
|
85 | 93 | throw new FileOperationException($e->getMessage(), $e->getCode(), $e); |
86 | 94 | } |
87 | 95 | |
@@ -99,10 +107,14 @@ discard block |
||
99 | 107 | ): FileInterface { |
100 | 108 | $fs = $this->getOperator(); |
101 | 109 | |
102 | - if ($storage === null || $storage === $this) { |
|
103 | - try { |
|
110 | + if ($storage === null || $storage === $this) |
|
111 | + { |
|
112 | + try |
|
113 | + { |
|
104 | 114 | $fs->copy($source, $destination, $config); |
105 | - } catch (FilesystemException $e) { |
|
115 | + } |
|
116 | + catch (FilesystemException $e) |
|
117 | + { |
|
106 | 118 | throw new FileOperationException($e->getMessage(), $e->getCode(), $e); |
107 | 119 | } |
108 | 120 | |
@@ -123,10 +135,14 @@ discard block |
||
123 | 135 | ): FileInterface { |
124 | 136 | $fs = $this->getOperator(); |
125 | 137 | |
126 | - if ($storage === null || $storage === $this) { |
|
127 | - try { |
|
138 | + if ($storage === null || $storage === $this) |
|
139 | + { |
|
140 | + try |
|
141 | + { |
|
128 | 142 | $fs->move($source, $destination, $config); |
129 | - } catch (FilesystemException $e) { |
|
143 | + } |
|
144 | + catch (FilesystemException $e) |
|
145 | + { |
|
130 | 146 | throw new FileOperationException($e->getMessage(), $e->getCode(), $e); |
131 | 147 | } |
132 | 148 | |
@@ -147,13 +163,17 @@ discard block |
||
147 | 163 | { |
148 | 164 | $fs = $this->getOperator(); |
149 | 165 | |
150 | - try { |
|
166 | + try |
|
167 | + { |
|
151 | 168 | $fs->delete($pathname); |
152 | 169 | |
153 | - if ($clean) { |
|
170 | + if ($clean) |
|
171 | + { |
|
154 | 172 | $this->deleteEmptyDirectories($this->getParentDirectory($pathname)); |
155 | 173 | } |
156 | - } catch (FilesystemException $e) { |
|
174 | + } |
|
175 | + catch (FilesystemException $e) |
|
176 | + { |
|
157 | 177 | throw new FileOperationException($e->getMessage(), $e->getCode(), $e); |
158 | 178 | } |
159 | 179 | } |
@@ -209,19 +229,24 @@ discard block |
||
209 | 229 | */ |
210 | 230 | private function deleteEmptyDirectories(string $directory): void |
211 | 231 | { |
212 | - if (!$this->hasParentDirectory($directory)) { |
|
232 | + if (!$this->hasParentDirectory($directory)) |
|
233 | + { |
|
213 | 234 | return; |
214 | 235 | } |
215 | 236 | |
216 | 237 | $fs = $this->getOperator(); |
217 | 238 | |
218 | - try { |
|
219 | - if (!$this->hasFiles($directory)) { |
|
239 | + try |
|
240 | + { |
|
241 | + if (!$this->hasFiles($directory)) |
|
242 | + { |
|
220 | 243 | $fs->deleteDirectory($directory); |
221 | 244 | |
222 | 245 | $this->deleteEmptyDirectories($this->getParentDirectory($directory)); |
223 | 246 | } |
224 | - } catch (FilesystemException $e) { |
|
247 | + } |
|
248 | + catch (FilesystemException $e) |
|
249 | + { |
|
225 | 250 | throw new FileOperationException($e->getMessage(), $e->getCode(), $e); |
226 | 251 | } |
227 | 252 | } |
@@ -243,7 +268,8 @@ discard block |
||
243 | 268 | { |
244 | 269 | $fs = $this->getOperator(); |
245 | 270 | |
246 | - foreach ($fs->listContents($directory) as $_) { |
|
271 | + foreach ($fs->listContents($directory) as $_) |
|
272 | + { |
|
247 | 273 | return true; |
248 | 274 | } |
249 | 275 | |
@@ -258,15 +284,18 @@ discard block |
||
258 | 284 | */ |
259 | 285 | private function isStringable($value): bool |
260 | 286 | { |
261 | - if (\is_string($value)) { |
|
287 | + if (\is_string($value)) |
|
288 | + { |
|
262 | 289 | return true; |
263 | 290 | } |
264 | 291 | |
265 | - if (!\is_object($value)) { |
|
292 | + if (!\is_object($value)) |
|
293 | + { |
|
266 | 294 | return false; |
267 | 295 | } |
268 | 296 | |
269 | - if (\PHP_VERSION_ID >= 80000) { |
|
297 | + if (\PHP_VERSION_ID >= 80000) |
|
298 | + { |
|
270 | 299 | return $value instanceof Stringable; |
271 | 300 | } |
272 | 301 |
@@ -22,11 +22,11 @@ |
||
22 | 22 | * @var string |
23 | 23 | * @psalm-var VisibilityType |
24 | 24 | */ |
25 | - public const VISIBILITY_PUBLIC = \League\Flysystem\Visibility::PUBLIC; |
|
25 | + public const VISIBILITY_PUBLIC = \League\Flysystem\Visibility::public; |
|
26 | 26 | |
27 | 27 | /** |
28 | 28 | * @var string |
29 | 29 | * @psalm-var VisibilityType |
30 | 30 | */ |
31 | - public const VISIBILITY_PRIVATE = \League\Flysystem\Visibility::PRIVATE; |
|
31 | + public const VISIBILITY_PRIVATE = \League\Flysystem\Visibility::private; |
|
32 | 32 | } |