@@ -73,7 +73,8 @@ |
||
73 | 73 | |
74 | 74 | protected function assertCloudFrontAvailable(): void |
75 | 75 | { |
76 | - if (\class_exists(UrlSigner::class)) { |
|
76 | + if (\class_exists(UrlSigner::class)) |
|
77 | + { |
|
77 | 78 | return; |
78 | 79 | } |
79 | 80 |
@@ -25,7 +25,7 @@ discard block |
||
25 | 25 | string $privateKey, |
26 | 26 | private readonly string $domain, |
27 | 27 | private readonly ?string $prefix = null, |
28 | - ) { |
|
28 | + ){ |
|
29 | 29 | $this->assertCloudFrontAvailable(); |
30 | 30 | $this->factory = new AmazonUriFactory(); |
31 | 31 | $this->signer = new UrlSigner($keyPairId, $privateKey); |
@@ -46,7 +46,7 @@ discard block |
||
46 | 46 | |
47 | 47 | protected function assertCloudFrontAvailable(): void |
48 | 48 | { |
49 | - if (\class_exists(UrlSigner::class)) { |
|
49 | + if (\class_exists(UrlSigner::class)){ |
|
50 | 50 | return; |
51 | 51 | } |
52 | 52 |
@@ -21,8 +21,8 @@ discard block |
||
21 | 21 | * @var string |
22 | 22 | */ |
23 | 23 | private const ERROR_NOT_AVAILABLE = |
24 | - 'The "aws/aws-sdk-php" package is supplied with the Guzzle PSR-7 ' . |
|
25 | - 'implementation, but it is not available. Please install the ' . |
|
24 | + 'The "aws/aws-sdk-php" package is supplied with the Guzzle PSR-7 '. |
|
25 | + 'implementation, but it is not available. Please install the '. |
|
26 | 26 | '"aws/aws-sdk-php" package or use any other implementation of PSR-17 factories.' |
27 | 27 | ; |
28 | 28 | |
@@ -41,7 +41,7 @@ discard block |
||
41 | 41 | |
42 | 42 | private function assertAvailable(): void |
43 | 43 | { |
44 | - if (\class_exists(Uri::class)) { |
|
44 | + if (\class_exists(Uri::class)){ |
|
45 | 45 | return; |
46 | 46 | } |
47 | 47 |
@@ -41,7 +41,8 @@ |
||
41 | 41 | |
42 | 42 | private function assertAvailable(): void |
43 | 43 | { |
44 | - if (\class_exists(Uri::class)) { |
|
44 | + if (\class_exists(Uri::class)) |
|
45 | + { |
|
45 | 46 | return; |
46 | 47 | } |
47 | 48 |
@@ -17,6 +17,6 @@ |
||
17 | 17 | { |
18 | 18 | // Do nothing |
19 | 19 | |
20 | - return (string) Uuid::uuid4(); |
|
20 | + return (string)Uuid::uuid4(); |
|
21 | 21 | } |
22 | 22 | } |
@@ -38,8 +38,10 @@ |
||
38 | 38 | public function locateCommands(): array |
39 | 39 | { |
40 | 40 | $commands = []; |
41 | - foreach ($this->classes->getScopedClasses('consoleCommands', SymfonyCommand::class) as $class) { |
|
42 | - if ($class->isAbstract()) { |
|
41 | + foreach ($this->classes->getScopedClasses('consoleCommands', SymfonyCommand::class) as $class) |
|
42 | + { |
|
43 | + if ($class->isAbstract()) |
|
44 | + { |
|
43 | 45 | continue; |
44 | 46 | } |
45 | 47 |
@@ -17,7 +17,7 @@ discard block |
||
17 | 17 | private readonly ScopedClassesInterface $classes, |
18 | 18 | ContainerInterface $container, |
19 | 19 | array $interceptors = [], |
20 | - ) { |
|
20 | + ){ |
|
21 | 21 | $this->container = $container; |
22 | 22 | $this->interceptors = $interceptors; |
23 | 23 | } |
@@ -25,8 +25,8 @@ discard block |
||
25 | 25 | public function locateCommands(): array |
26 | 26 | { |
27 | 27 | $commands = []; |
28 | - foreach ($this->classes->getScopedClasses('consoleCommands', SymfonyCommand::class) as $class) { |
|
29 | - if ($class->isAbstract()) { |
|
28 | + foreach ($this->classes->getScopedClasses('consoleCommands', SymfonyCommand::class) as $class){ |
|
29 | + if ($class->isAbstract()){ |
|
30 | 30 | continue; |
31 | 31 | } |
32 | 32 |
@@ -47,7 +47,7 @@ |
||
47 | 47 | 'directories' => [], |
48 | 48 | 'scopes' => [ |
49 | 49 | 'prototypes' => [ |
50 | - 'directories' => [__DIR__ . '/Fixtures'] |
|
50 | + 'directories' => [__DIR__.'/Fixtures'] |
|
51 | 51 | ] |
52 | 52 | ] |
53 | 53 | ]))); |
@@ -23,7 +23,7 @@ |
||
23 | 23 | /** |
24 | 24 | * Default file mode for this manager. |
25 | 25 | */ |
26 | - public const DEFAULT_FILE_MODE = self::READONLY; |
|
26 | + public const DEFAULT_FILE_MODE = self::readonly; |
|
27 | 27 | |
28 | 28 | /** |
29 | 29 | * Files to be removed when component destructed. |
@@ -39,30 +39,30 @@ discard block |
||
39 | 39 | ?int $mode = null, |
40 | 40 | bool $recursivePermissions = true, |
41 | 41 | ): bool { |
42 | - if (empty($mode)) { |
|
42 | + if (empty($mode)){ |
|
43 | 43 | $mode = self::DEFAULT_FILE_MODE; |
44 | 44 | } |
45 | 45 | |
46 | 46 | //Directories always executable |
47 | 47 | $mode |= 0o111; |
48 | - if (\is_dir($directory)) { |
|
48 | + if (\is_dir($directory)){ |
|
49 | 49 | //Exists :( |
50 | 50 | return $this->setPermissions($directory, $mode); |
51 | 51 | } |
52 | 52 | |
53 | - if (!$recursivePermissions) { |
|
53 | + if (!$recursivePermissions){ |
|
54 | 54 | return \mkdir($directory, $mode, true); |
55 | 55 | } |
56 | 56 | |
57 | 57 | $directoryChain = [\basename($directory)]; |
58 | 58 | |
59 | 59 | $baseDirectory = $directory; |
60 | - while (!\is_dir($baseDirectory = \dirname($baseDirectory))) { |
|
60 | + while (!\is_dir($baseDirectory = \dirname($baseDirectory))){ |
|
61 | 61 | $directoryChain[] = \basename($baseDirectory); |
62 | 62 | } |
63 | 63 | |
64 | - foreach (\array_reverse($directoryChain) as $dir) { |
|
65 | - if (!\mkdir($baseDirectory = \sprintf('%s/%s', $baseDirectory, $dir))) { |
|
64 | + foreach (\array_reverse($directoryChain) as $dir){ |
|
65 | + if (!\mkdir($baseDirectory = \sprintf('%s/%s', $baseDirectory, $dir))){ |
|
66 | 66 | return false; |
67 | 67 | } |
68 | 68 | |
@@ -74,7 +74,7 @@ discard block |
||
74 | 74 | |
75 | 75 | public function read(string $filename): string |
76 | 76 | { |
77 | - if (!$this->exists($filename)) { |
|
77 | + if (!$this->exists($filename)){ |
|
78 | 78 | throw new FileNotFoundException($filename); |
79 | 79 | } |
80 | 80 | |
@@ -93,12 +93,12 @@ discard block |
||
93 | 93 | ): bool { |
94 | 94 | $mode ??= self::DEFAULT_FILE_MODE; |
95 | 95 | |
96 | - try { |
|
97 | - if ($ensureDirectory) { |
|
96 | + try{ |
|
97 | + if ($ensureDirectory){ |
|
98 | 98 | $this->ensureDirectory(\dirname($filename), $mode); |
99 | 99 | } |
100 | 100 | |
101 | - if ($this->exists($filename)) { |
|
101 | + if ($this->exists($filename)){ |
|
102 | 102 | //Forcing mode for existed file |
103 | 103 | $this->setPermissions($filename, $mode); |
104 | 104 | } |
@@ -109,12 +109,12 @@ discard block |
||
109 | 109 | $append ? FILE_APPEND | LOCK_EX : LOCK_EX, |
110 | 110 | ); |
111 | 111 | |
112 | - if ($result !== false) { |
|
112 | + if ($result !== false){ |
|
113 | 113 | //Forcing mode after file creation |
114 | 114 | $this->setPermissions($filename, $mode); |
115 | 115 | } |
116 | - } catch (\Exception $e) { |
|
117 | - throw new WriteErrorException($e->getMessage(), (int) $e->getCode(), $e); |
|
116 | + }catch (\Exception $e){ |
|
117 | + throw new WriteErrorException($e->getMessage(), (int)$e->getCode(), $e); |
|
118 | 118 | } |
119 | 119 | |
120 | 120 | return $result !== false; |
@@ -131,7 +131,7 @@ discard block |
||
131 | 131 | |
132 | 132 | public function delete(string $filename): bool |
133 | 133 | { |
134 | - if ($this->exists($filename)) { |
|
134 | + if ($this->exists($filename)){ |
|
135 | 135 | $result = \unlink($filename); |
136 | 136 | |
137 | 137 | //Wiping out changes in local file cache |
@@ -150,7 +150,7 @@ discard block |
||
150 | 150 | */ |
151 | 151 | public function deleteDirectory(string $directory, bool $contentOnly = false): bool |
152 | 152 | { |
153 | - if (!$this->isDirectory($directory)) { |
|
153 | + if (!$this->isDirectory($directory)){ |
|
154 | 154 | throw new FilesException(\sprintf('Undefined or invalid directory %s', $directory)); |
155 | 155 | } |
156 | 156 | |
@@ -159,15 +159,15 @@ discard block |
||
159 | 159 | \RecursiveIteratorIterator::CHILD_FIRST, |
160 | 160 | ); |
161 | 161 | |
162 | - foreach ($files as $file) { |
|
163 | - if ($file->isDir()) { |
|
162 | + foreach ($files as $file){ |
|
163 | + if ($file->isDir()){ |
|
164 | 164 | \rmdir($file->getRealPath()); |
165 | - } else { |
|
165 | + }else{ |
|
166 | 166 | $this->delete($file->getRealPath()); |
167 | 167 | } |
168 | 168 | } |
169 | 169 | |
170 | - if (!$contentOnly) { |
|
170 | + if (!$contentOnly){ |
|
171 | 171 | return \rmdir($directory); |
172 | 172 | } |
173 | 173 | |
@@ -176,7 +176,7 @@ discard block |
||
176 | 176 | |
177 | 177 | public function move(string $filename, string $destination): bool |
178 | 178 | { |
179 | - if (!$this->exists($filename)) { |
|
179 | + if (!$this->exists($filename)){ |
|
180 | 180 | throw new FileNotFoundException($filename); |
181 | 181 | } |
182 | 182 | |
@@ -185,7 +185,7 @@ discard block |
||
185 | 185 | |
186 | 186 | public function copy(string $filename, string $destination): bool |
187 | 187 | { |
188 | - if (!$this->exists($filename)) { |
|
188 | + if (!$this->exists($filename)){ |
|
189 | 189 | throw new FileNotFoundException($filename); |
190 | 190 | } |
191 | 191 | |
@@ -194,7 +194,7 @@ discard block |
||
194 | 194 | |
195 | 195 | public function touch(string $filename, ?int $mode = null): bool |
196 | 196 | { |
197 | - if (!\touch($filename)) { |
|
197 | + if (!\touch($filename)){ |
|
198 | 198 | return false; |
199 | 199 | } |
200 | 200 | |
@@ -208,7 +208,7 @@ discard block |
||
208 | 208 | |
209 | 209 | public function size(string $filename): int |
210 | 210 | { |
211 | - if (!$this->exists($filename)) { |
|
211 | + if (!$this->exists($filename)){ |
|
212 | 212 | throw new FileNotFoundException($filename); |
213 | 213 | } |
214 | 214 | |
@@ -222,7 +222,7 @@ discard block |
||
222 | 222 | |
223 | 223 | public function md5(string $filename): string |
224 | 224 | { |
225 | - if (!$this->exists($filename)) { |
|
225 | + if (!$this->exists($filename)){ |
|
226 | 226 | throw new FileNotFoundException($filename); |
227 | 227 | } |
228 | 228 | |
@@ -231,7 +231,7 @@ discard block |
||
231 | 231 | |
232 | 232 | public function time(string $filename): int |
233 | 233 | { |
234 | - if (!$this->exists($filename)) { |
|
234 | + if (!$this->exists($filename)){ |
|
235 | 235 | throw new FileNotFoundException($filename); |
236 | 236 | } |
237 | 237 | |
@@ -250,7 +250,7 @@ discard block |
||
250 | 250 | |
251 | 251 | public function getPermissions(string $filename): int |
252 | 252 | { |
253 | - if (!$this->exists($filename)) { |
|
253 | + if (!$this->exists($filename)){ |
|
254 | 254 | throw new FileNotFoundException($filename); |
255 | 255 | } |
256 | 256 | |
@@ -259,7 +259,7 @@ discard block |
||
259 | 259 | |
260 | 260 | public function setPermissions(string $filename, int $mode): bool |
261 | 261 | { |
262 | - if (\is_dir($filename)) { |
|
262 | + if (\is_dir($filename)){ |
|
263 | 263 | //Directories must always be executable (i.e. 664 for dir => 775) |
264 | 264 | $mode |= 0111; |
265 | 265 | } |
@@ -270,14 +270,14 @@ discard block |
||
270 | 270 | public function getFiles(string $location, ?string $pattern = null): array |
271 | 271 | { |
272 | 272 | $result = []; |
273 | - foreach ($this->filesIterator($location, $pattern) as $filename) { |
|
274 | - if ($this->isDirectory($filename->getPathname())) { |
|
275 | - $result = \array_merge($result, $this->getFiles($filename . DIRECTORY_SEPARATOR)); |
|
273 | + foreach ($this->filesIterator($location, $pattern) as $filename){ |
|
274 | + if ($this->isDirectory($filename->getPathname())){ |
|
275 | + $result = \array_merge($result, $this->getFiles($filename.DIRECTORY_SEPARATOR)); |
|
276 | 276 | |
277 | 277 | continue; |
278 | 278 | } |
279 | 279 | |
280 | - $result[] = $this->normalizePath((string) $filename); |
|
280 | + $result[] = $this->normalizePath((string)$filename); |
|
281 | 281 | } |
282 | 282 | |
283 | 283 | return $result; |
@@ -285,13 +285,13 @@ discard block |
||
285 | 285 | |
286 | 286 | public function tempFilename(string $extension = '', ?string $location = null): string |
287 | 287 | { |
288 | - if (empty($location)) { |
|
288 | + if (empty($location)){ |
|
289 | 289 | $location = \sys_get_temp_dir(); |
290 | 290 | } |
291 | 291 | |
292 | 292 | $filename = \tempnam($location, 'spiral'); |
293 | 293 | |
294 | - if (!empty($extension)) { |
|
294 | + if (!empty($extension)){ |
|
295 | 295 | $old = $filename; |
296 | 296 | $filename = \sprintf('%s.%s', $filename, $extension); |
297 | 297 | \rename($old, $filename); |
@@ -304,7 +304,7 @@ discard block |
||
304 | 304 | public function normalizePath(string $path, bool $asDirectory = false): string |
305 | 305 | { |
306 | 306 | $isUnc = \str_starts_with($path, '\\\\') || \str_starts_with($path, '//'); |
307 | - if ($isUnc) { |
|
307 | + if ($isUnc){ |
|
308 | 308 | $leadingSlashes = \substr($path, 0, 2); |
309 | 309 | $path = \substr($path, 2); |
310 | 310 | } |
@@ -312,7 +312,7 @@ discard block |
||
312 | 312 | $path = \str_replace(['//', '\\'], '/', $path); |
313 | 313 | |
314 | 314 | //Potentially open links and ../ type directories? |
315 | - return ($isUnc ? $leadingSlashes : '') . \rtrim($path, '/') . ($asDirectory ? '/' : ''); |
|
315 | + return ($isUnc ? $leadingSlashes : '').\rtrim($path, '/').($asDirectory ? '/' : ''); |
|
316 | 316 | } |
317 | 317 | |
318 | 318 | /** |
@@ -327,21 +327,21 @@ discard block |
||
327 | 327 | $path = \explode('/', $path); |
328 | 328 | $relative = $path; |
329 | 329 | |
330 | - foreach ($from as $depth => $dir) { |
|
330 | + foreach ($from as $depth => $dir){ |
|
331 | 331 | //Find first non-matching dir |
332 | - if ($dir === $path[$depth]) { |
|
332 | + if ($dir === $path[$depth]){ |
|
333 | 333 | //Ignore this directory |
334 | 334 | \array_shift($relative); |
335 | - } else { |
|
335 | + }else{ |
|
336 | 336 | //Get number of remaining dirs to $from |
337 | 337 | $remaining = \count($from) - $depth; |
338 | - if ($remaining > 1) { |
|
338 | + if ($remaining > 1){ |
|
339 | 339 | //Add traversals up to first matching directory |
340 | 340 | $padLength = (\count($relative) + $remaining - 1) * -1; |
341 | 341 | $relative = \array_pad($relative, $padLength, '..'); |
342 | 342 | break; |
343 | 343 | } |
344 | - $relative[0] = './' . $relative[0]; |
|
344 | + $relative[0] = './'.$relative[0]; |
|
345 | 345 | } |
346 | 346 | } |
347 | 347 | |
@@ -353,7 +353,7 @@ discard block |
||
353 | 353 | */ |
354 | 354 | public function __destruct() |
355 | 355 | { |
356 | - foreach ($this->destructFiles as $filename) { |
|
356 | + foreach ($this->destructFiles as $filename){ |
|
357 | 357 | $this->delete($filename); |
358 | 358 | } |
359 | 359 | } |
@@ -361,7 +361,7 @@ discard block |
||
361 | 361 | private function filesIterator(string $location, ?string $pattern = null): \GlobIterator |
362 | 362 | { |
363 | 363 | $pattern ??= '*'; |
364 | - $regexp = \rtrim($location, DIRECTORY_SEPARATOR) . DIRECTORY_SEPARATOR . \ltrim($pattern, DIRECTORY_SEPARATOR); |
|
364 | + $regexp = \rtrim($location, DIRECTORY_SEPARATOR).DIRECTORY_SEPARATOR.\ltrim($pattern, DIRECTORY_SEPARATOR); |
|
365 | 365 | |
366 | 366 | return new \GlobIterator($regexp); |
367 | 367 | } |
@@ -39,30 +39,36 @@ discard block |
||
39 | 39 | ?int $mode = null, |
40 | 40 | bool $recursivePermissions = true, |
41 | 41 | ): bool { |
42 | - if (empty($mode)) { |
|
42 | + if (empty($mode)) |
|
43 | + { |
|
43 | 44 | $mode = self::DEFAULT_FILE_MODE; |
44 | 45 | } |
45 | 46 | |
46 | 47 | //Directories always executable |
47 | 48 | $mode |= 0o111; |
48 | - if (\is_dir($directory)) { |
|
49 | + if (\is_dir($directory)) |
|
50 | + { |
|
49 | 51 | //Exists :( |
50 | 52 | return $this->setPermissions($directory, $mode); |
51 | 53 | } |
52 | 54 | |
53 | - if (!$recursivePermissions) { |
|
55 | + if (!$recursivePermissions) |
|
56 | + { |
|
54 | 57 | return \mkdir($directory, $mode, true); |
55 | 58 | } |
56 | 59 | |
57 | 60 | $directoryChain = [\basename($directory)]; |
58 | 61 | |
59 | 62 | $baseDirectory = $directory; |
60 | - while (!\is_dir($baseDirectory = \dirname($baseDirectory))) { |
|
63 | + while (!\is_dir($baseDirectory = \dirname($baseDirectory))) |
|
64 | + { |
|
61 | 65 | $directoryChain[] = \basename($baseDirectory); |
62 | 66 | } |
63 | 67 | |
64 | - foreach (\array_reverse($directoryChain) as $dir) { |
|
65 | - if (!\mkdir($baseDirectory = \sprintf('%s/%s', $baseDirectory, $dir))) { |
|
68 | + foreach (\array_reverse($directoryChain) as $dir) |
|
69 | + { |
|
70 | + if (!\mkdir($baseDirectory = \sprintf('%s/%s', $baseDirectory, $dir))) |
|
71 | + { |
|
66 | 72 | return false; |
67 | 73 | } |
68 | 74 | |
@@ -74,7 +80,8 @@ discard block |
||
74 | 80 | |
75 | 81 | public function read(string $filename): string |
76 | 82 | { |
77 | - if (!$this->exists($filename)) { |
|
83 | + if (!$this->exists($filename)) |
|
84 | + { |
|
78 | 85 | throw new FileNotFoundException($filename); |
79 | 86 | } |
80 | 87 | |
@@ -93,12 +100,15 @@ discard block |
||
93 | 100 | ): bool { |
94 | 101 | $mode ??= self::DEFAULT_FILE_MODE; |
95 | 102 | |
96 | - try { |
|
97 | - if ($ensureDirectory) { |
|
103 | + try |
|
104 | + { |
|
105 | + if ($ensureDirectory) |
|
106 | + { |
|
98 | 107 | $this->ensureDirectory(\dirname($filename), $mode); |
99 | 108 | } |
100 | 109 | |
101 | - if ($this->exists($filename)) { |
|
110 | + if ($this->exists($filename)) |
|
111 | + { |
|
102 | 112 | //Forcing mode for existed file |
103 | 113 | $this->setPermissions($filename, $mode); |
104 | 114 | } |
@@ -109,11 +119,14 @@ discard block |
||
109 | 119 | $append ? FILE_APPEND | LOCK_EX : LOCK_EX, |
110 | 120 | ); |
111 | 121 | |
112 | - if ($result !== false) { |
|
122 | + if ($result !== false) |
|
123 | + { |
|
113 | 124 | //Forcing mode after file creation |
114 | 125 | $this->setPermissions($filename, $mode); |
115 | 126 | } |
116 | - } catch (\Exception $e) { |
|
127 | + } |
|
128 | + catch (\Exception $e) |
|
129 | + { |
|
117 | 130 | throw new WriteErrorException($e->getMessage(), (int) $e->getCode(), $e); |
118 | 131 | } |
119 | 132 | |
@@ -131,7 +144,8 @@ discard block |
||
131 | 144 | |
132 | 145 | public function delete(string $filename): bool |
133 | 146 | { |
134 | - if ($this->exists($filename)) { |
|
147 | + if ($this->exists($filename)) |
|
148 | + { |
|
135 | 149 | $result = \unlink($filename); |
136 | 150 | |
137 | 151 | //Wiping out changes in local file cache |
@@ -150,7 +164,8 @@ discard block |
||
150 | 164 | */ |
151 | 165 | public function deleteDirectory(string $directory, bool $contentOnly = false): bool |
152 | 166 | { |
153 | - if (!$this->isDirectory($directory)) { |
|
167 | + if (!$this->isDirectory($directory)) |
|
168 | + { |
|
154 | 169 | throw new FilesException(\sprintf('Undefined or invalid directory %s', $directory)); |
155 | 170 | } |
156 | 171 | |
@@ -159,15 +174,20 @@ discard block |
||
159 | 174 | \RecursiveIteratorIterator::CHILD_FIRST, |
160 | 175 | ); |
161 | 176 | |
162 | - foreach ($files as $file) { |
|
163 | - if ($file->isDir()) { |
|
177 | + foreach ($files as $file) |
|
178 | + { |
|
179 | + if ($file->isDir()) |
|
180 | + { |
|
164 | 181 | \rmdir($file->getRealPath()); |
165 | - } else { |
|
182 | + } |
|
183 | + else |
|
184 | + { |
|
166 | 185 | $this->delete($file->getRealPath()); |
167 | 186 | } |
168 | 187 | } |
169 | 188 | |
170 | - if (!$contentOnly) { |
|
189 | + if (!$contentOnly) |
|
190 | + { |
|
171 | 191 | return \rmdir($directory); |
172 | 192 | } |
173 | 193 | |
@@ -176,7 +196,8 @@ discard block |
||
176 | 196 | |
177 | 197 | public function move(string $filename, string $destination): bool |
178 | 198 | { |
179 | - if (!$this->exists($filename)) { |
|
199 | + if (!$this->exists($filename)) |
|
200 | + { |
|
180 | 201 | throw new FileNotFoundException($filename); |
181 | 202 | } |
182 | 203 | |
@@ -185,7 +206,8 @@ discard block |
||
185 | 206 | |
186 | 207 | public function copy(string $filename, string $destination): bool |
187 | 208 | { |
188 | - if (!$this->exists($filename)) { |
|
209 | + if (!$this->exists($filename)) |
|
210 | + { |
|
189 | 211 | throw new FileNotFoundException($filename); |
190 | 212 | } |
191 | 213 | |
@@ -194,7 +216,8 @@ discard block |
||
194 | 216 | |
195 | 217 | public function touch(string $filename, ?int $mode = null): bool |
196 | 218 | { |
197 | - if (!\touch($filename)) { |
|
219 | + if (!\touch($filename)) |
|
220 | + { |
|
198 | 221 | return false; |
199 | 222 | } |
200 | 223 | |
@@ -208,7 +231,8 @@ discard block |
||
208 | 231 | |
209 | 232 | public function size(string $filename): int |
210 | 233 | { |
211 | - if (!$this->exists($filename)) { |
|
234 | + if (!$this->exists($filename)) |
|
235 | + { |
|
212 | 236 | throw new FileNotFoundException($filename); |
213 | 237 | } |
214 | 238 | |
@@ -222,7 +246,8 @@ discard block |
||
222 | 246 | |
223 | 247 | public function md5(string $filename): string |
224 | 248 | { |
225 | - if (!$this->exists($filename)) { |
|
249 | + if (!$this->exists($filename)) |
|
250 | + { |
|
226 | 251 | throw new FileNotFoundException($filename); |
227 | 252 | } |
228 | 253 | |
@@ -231,7 +256,8 @@ discard block |
||
231 | 256 | |
232 | 257 | public function time(string $filename): int |
233 | 258 | { |
234 | - if (!$this->exists($filename)) { |
|
259 | + if (!$this->exists($filename)) |
|
260 | + { |
|
235 | 261 | throw new FileNotFoundException($filename); |
236 | 262 | } |
237 | 263 | |
@@ -250,7 +276,8 @@ discard block |
||
250 | 276 | |
251 | 277 | public function getPermissions(string $filename): int |
252 | 278 | { |
253 | - if (!$this->exists($filename)) { |
|
279 | + if (!$this->exists($filename)) |
|
280 | + { |
|
254 | 281 | throw new FileNotFoundException($filename); |
255 | 282 | } |
256 | 283 | |
@@ -259,7 +286,8 @@ discard block |
||
259 | 286 | |
260 | 287 | public function setPermissions(string $filename, int $mode): bool |
261 | 288 | { |
262 | - if (\is_dir($filename)) { |
|
289 | + if (\is_dir($filename)) |
|
290 | + { |
|
263 | 291 | //Directories must always be executable (i.e. 664 for dir => 775) |
264 | 292 | $mode |= 0111; |
265 | 293 | } |
@@ -270,8 +298,10 @@ discard block |
||
270 | 298 | public function getFiles(string $location, ?string $pattern = null): array |
271 | 299 | { |
272 | 300 | $result = []; |
273 | - foreach ($this->filesIterator($location, $pattern) as $filename) { |
|
274 | - if ($this->isDirectory($filename->getPathname())) { |
|
301 | + foreach ($this->filesIterator($location, $pattern) as $filename) |
|
302 | + { |
|
303 | + if ($this->isDirectory($filename->getPathname())) |
|
304 | + { |
|
275 | 305 | $result = \array_merge($result, $this->getFiles($filename . DIRECTORY_SEPARATOR)); |
276 | 306 | |
277 | 307 | continue; |
@@ -285,13 +315,15 @@ discard block |
||
285 | 315 | |
286 | 316 | public function tempFilename(string $extension = '', ?string $location = null): string |
287 | 317 | { |
288 | - if (empty($location)) { |
|
318 | + if (empty($location)) |
|
319 | + { |
|
289 | 320 | $location = \sys_get_temp_dir(); |
290 | 321 | } |
291 | 322 | |
292 | 323 | $filename = \tempnam($location, 'spiral'); |
293 | 324 | |
294 | - if (!empty($extension)) { |
|
325 | + if (!empty($extension)) |
|
326 | + { |
|
295 | 327 | $old = $filename; |
296 | 328 | $filename = \sprintf('%s.%s', $filename, $extension); |
297 | 329 | \rename($old, $filename); |
@@ -304,7 +336,8 @@ discard block |
||
304 | 336 | public function normalizePath(string $path, bool $asDirectory = false): string |
305 | 337 | { |
306 | 338 | $isUnc = \str_starts_with($path, '\\\\') || \str_starts_with($path, '//'); |
307 | - if ($isUnc) { |
|
339 | + if ($isUnc) |
|
340 | + { |
|
308 | 341 | $leadingSlashes = \substr($path, 0, 2); |
309 | 342 | $path = \substr($path, 2); |
310 | 343 | } |
@@ -327,15 +360,20 @@ discard block |
||
327 | 360 | $path = \explode('/', $path); |
328 | 361 | $relative = $path; |
329 | 362 | |
330 | - foreach ($from as $depth => $dir) { |
|
363 | + foreach ($from as $depth => $dir) |
|
364 | + { |
|
331 | 365 | //Find first non-matching dir |
332 | - if ($dir === $path[$depth]) { |
|
366 | + if ($dir === $path[$depth]) |
|
367 | + { |
|
333 | 368 | //Ignore this directory |
334 | 369 | \array_shift($relative); |
335 | - } else { |
|
370 | + } |
|
371 | + else |
|
372 | + { |
|
336 | 373 | //Get number of remaining dirs to $from |
337 | 374 | $remaining = \count($from) - $depth; |
338 | - if ($remaining > 1) { |
|
375 | + if ($remaining > 1) |
|
376 | + { |
|
339 | 377 | //Add traversals up to first matching directory |
340 | 378 | $padLength = (\count($relative) + $remaining - 1) * -1; |
341 | 379 | $relative = \array_pad($relative, $padLength, '..'); |
@@ -353,7 +391,8 @@ discard block |
||
353 | 391 | */ |
354 | 392 | public function __destruct() |
355 | 393 | { |
356 | - foreach ($this->destructFiles as $filename) { |
|
394 | + foreach ($this->destructFiles as $filename) |
|
395 | + { |
|
357 | 396 | $this->delete($filename); |
358 | 397 | } |
359 | 398 | } |
@@ -23,7 +23,7 @@ |
||
23 | 23 | public const RUNTIME = 0666; |
24 | 24 | |
25 | 25 | //Only owner can write |
26 | - public const READONLY = 0644; |
|
26 | + public const readonly = 0644; |
|
27 | 27 | |
28 | 28 | /** |
29 | 29 | * Few size constants for better size manipulations. |
@@ -58,10 +58,10 @@ |
||
58 | 58 | */ |
59 | 59 | public function getChunkSize(): ?int |
60 | 60 | { |
61 | - if (\is_null($this->config['chunkSize']) || (int) $this->config['chunkSize'] < 0) { |
|
61 | + if (\is_null($this->config['chunkSize']) || (int)$this->config['chunkSize'] < 0){ |
|
62 | 62 | return null; |
63 | 63 | } |
64 | 64 | |
65 | - return (int) $this->config['chunkSize']; |
|
65 | + return (int)$this->config['chunkSize']; |
|
66 | 66 | } |
67 | 67 | } |
@@ -58,7 +58,8 @@ |
||
58 | 58 | */ |
59 | 59 | public function getChunkSize(): ?int |
60 | 60 | { |
61 | - if (\is_null($this->config['chunkSize']) || (int) $this->config['chunkSize'] < 0) { |
|
61 | + if (\is_null($this->config['chunkSize']) || (int) $this->config['chunkSize'] < 0) |
|
62 | + { |
|
62 | 63 | return null; |
63 | 64 | } |
64 | 65 |
@@ -43,15 +43,15 @@ |
||
43 | 43 | */ |
44 | 44 | public function getHandler(): ?Autowire |
45 | 45 | { |
46 | - if (empty($this->config['handler'])) { |
|
46 | + if (empty($this->config['handler'])){ |
|
47 | 47 | return null; |
48 | 48 | } |
49 | 49 | |
50 | - if ($this->config['handler'] instanceof Autowire) { |
|
50 | + if ($this->config['handler'] instanceof Autowire){ |
|
51 | 51 | return $this->config['handler']; |
52 | 52 | } |
53 | 53 | |
54 | - if (\class_exists($this->config['handler'])) { |
|
54 | + if (\class_exists($this->config['handler'])){ |
|
55 | 55 | return new Autowire($this->config['handler']); |
56 | 56 | } |
57 | 57 |
@@ -43,15 +43,18 @@ |
||
43 | 43 | */ |
44 | 44 | public function getHandler(): ?Autowire |
45 | 45 | { |
46 | - if (empty($this->config['handler'])) { |
|
46 | + if (empty($this->config['handler'])) |
|
47 | + { |
|
47 | 48 | return null; |
48 | 49 | } |
49 | 50 | |
50 | - if ($this->config['handler'] instanceof Autowire) { |
|
51 | + if ($this->config['handler'] instanceof Autowire) |
|
52 | + { |
|
51 | 53 | return $this->config['handler']; |
52 | 54 | } |
53 | 55 | |
54 | - if (\class_exists($this->config['handler'])) { |
|
56 | + if (\class_exists($this->config['handler'])) |
|
57 | + { |
|
55 | 58 | return new Autowire($this->config['handler']); |
56 | 59 | } |
57 | 60 |