@@ -32,7 +32,7 @@ |
||
| 32 | 32 | */ |
| 33 | 33 | public function patch(array $config): array |
| 34 | 34 | { |
| 35 | - foreach ($this->patches as $patch) { |
|
| 35 | + foreach ($this->patches as $patch){ |
|
| 36 | 36 | $config = $patch->patch($config); |
| 37 | 37 | } |
| 38 | 38 | |
@@ -32,7 +32,8 @@ |
||
| 32 | 32 | */ |
| 33 | 33 | public function patch(array $config): array |
| 34 | 34 | { |
| 35 | - foreach ($this->patches as $patch) { |
|
| 35 | + foreach ($this->patches as $patch) |
|
| 36 | + { |
|
| 36 | 37 | $config = $patch->patch($config); |
| 37 | 38 | } |
| 38 | 39 | |
@@ -46,15 +46,15 @@ |
||
| 46 | 46 | */ |
| 47 | 47 | public function patch(array $config): array |
| 48 | 48 | { |
| 49 | - try { |
|
| 49 | + try{ |
|
| 50 | 50 | $target = &$this->dotGet($config, $this->position); |
| 51 | 51 | |
| 52 | - if ($this->key !== null) { |
|
| 52 | + if ($this->key !== null){ |
|
| 53 | 53 | $target[$this->key] = $this->value; |
| 54 | - } else { |
|
| 54 | + }else{ |
|
| 55 | 55 | $target[] = $this->value; |
| 56 | 56 | } |
| 57 | - } catch (DotNotFoundException $e) { |
|
| 57 | + }catch (DotNotFoundException $e){ |
|
| 58 | 58 | throw new PatchException($e->getMessage(), $e->getCode(), $e); |
| 59 | 59 | } |
| 60 | 60 | |
@@ -46,15 +46,21 @@ |
||
| 46 | 46 | */ |
| 47 | 47 | public function patch(array $config): array |
| 48 | 48 | { |
| 49 | - try { |
|
| 49 | + try |
|
| 50 | + { |
|
| 50 | 51 | $target = &$this->dotGet($config, $this->position); |
| 51 | 52 | |
| 52 | - if ($this->key !== null) { |
|
| 53 | + if ($this->key !== null) |
|
| 54 | + { |
|
| 53 | 55 | $target[$this->key] = $this->value; |
| 54 | - } else { |
|
| 56 | + } |
|
| 57 | + else |
|
| 58 | + { |
|
| 55 | 59 | $target[] = $this->value; |
| 56 | 60 | } |
| 57 | - } catch (DotNotFoundException $e) { |
|
| 61 | + } |
|
| 62 | + catch (DotNotFoundException $e) |
|
| 63 | + { |
|
| 58 | 64 | throw new PatchException($e->getMessage(), $e->getCode(), $e); |
| 59 | 65 | } |
| 60 | 66 | |
@@ -23,14 +23,14 @@ |
||
| 23 | 23 | private function &dotGet(array &$data, string $name) |
| 24 | 24 | { |
| 25 | 25 | //Generating path relative to a given name and prefix |
| 26 | - $path = (!empty($this->prefix) ? $this->prefix . '.' : '') . $name; |
|
| 27 | - if (empty($path)) { |
|
| 26 | + $path = (!empty($this->prefix) ? $this->prefix.'.' : '').$name; |
|
| 27 | + if (empty($path)){ |
|
| 28 | 28 | return $data; |
| 29 | 29 | } |
| 30 | 30 | |
| 31 | 31 | $path = explode('.', rtrim($path, '.')); |
| 32 | - foreach ($path as $step) { |
|
| 33 | - if (!is_array($data) || !array_key_exists($step, $data)) { |
|
| 32 | + foreach ($path as $step){ |
|
| 33 | + if (!is_array($data) || !array_key_exists($step, $data)){ |
|
| 34 | 34 | throw new DotNotFoundException("Unable to find config element '{$name}'."); |
| 35 | 35 | } |
| 36 | 36 | $data = &$data[$step]; |
@@ -24,13 +24,16 @@ |
||
| 24 | 24 | { |
| 25 | 25 | //Generating path relative to a given name and prefix |
| 26 | 26 | $path = (!empty($this->prefix) ? $this->prefix . '.' : '') . $name; |
| 27 | - if (empty($path)) { |
|
| 27 | + if (empty($path)) |
|
| 28 | + { |
|
| 28 | 29 | return $data; |
| 29 | 30 | } |
| 30 | 31 | |
| 31 | 32 | $path = explode('.', rtrim($path, '.')); |
| 32 | - foreach ($path as $step) { |
|
| 33 | - if (!is_array($data) || !array_key_exists($step, $data)) { |
|
| 33 | + foreach ($path as $step) |
|
| 34 | + { |
|
| 35 | + if (!is_array($data) || !array_key_exists($step, $data)) |
|
| 36 | + { |
|
| 34 | 37 | throw new DotNotFoundException("Unable to find config element '{$name}'."); |
| 35 | 38 | } |
| 36 | 39 | $data = &$data[$step]; |
@@ -46,15 +46,15 @@ |
||
| 46 | 46 | */ |
| 47 | 47 | public function patch(array $config): array |
| 48 | 48 | { |
| 49 | - try { |
|
| 49 | + try{ |
|
| 50 | 50 | $target = &$this->dotGet($config, $this->position); |
| 51 | 51 | |
| 52 | - if ($this->key !== null) { |
|
| 52 | + if ($this->key !== null){ |
|
| 53 | 53 | $target = array_merge([$this->key => $this->value], $target); |
| 54 | - } else { |
|
| 54 | + }else{ |
|
| 55 | 55 | array_unshift($target, $this->value); |
| 56 | 56 | } |
| 57 | - } catch (DotNotFoundException $e) { |
|
| 57 | + }catch (DotNotFoundException $e){ |
|
| 58 | 58 | throw new PatchException($e->getMessage(), $e->getCode(), $e); |
| 59 | 59 | } |
| 60 | 60 | |
@@ -46,15 +46,21 @@ |
||
| 46 | 46 | */ |
| 47 | 47 | public function patch(array $config): array |
| 48 | 48 | { |
| 49 | - try { |
|
| 49 | + try |
|
| 50 | + { |
|
| 50 | 51 | $target = &$this->dotGet($config, $this->position); |
| 51 | 52 | |
| 52 | - if ($this->key !== null) { |
|
| 53 | + if ($this->key !== null) |
|
| 54 | + { |
|
| 53 | 55 | $target = array_merge([$this->key => $this->value], $target); |
| 54 | - } else { |
|
| 56 | + } |
|
| 57 | + else |
|
| 58 | + { |
|
| 55 | 59 | array_unshift($target, $this->value); |
| 56 | 60 | } |
| 57 | - } catch (DotNotFoundException $e) { |
|
| 61 | + } |
|
| 62 | + catch (DotNotFoundException $e) |
|
| 63 | + { |
|
| 58 | 64 | throw new PatchException($e->getMessage(), $e->getCode(), $e); |
| 59 | 65 | } |
| 60 | 66 | |
@@ -30,8 +30,8 @@ |
||
| 30 | 30 | |
| 31 | 31 | protected function getFactory(string $directory = null, bool $strict = true): ConfigManager |
| 32 | 32 | { |
| 33 | - if (is_null($directory)) { |
|
| 34 | - $directory = __DIR__ . '/fixtures'; |
|
| 33 | + if (is_null($directory)){ |
|
| 34 | + $directory = __DIR__.'/fixtures'; |
|
| 35 | 35 | } |
| 36 | 36 | |
| 37 | 37 | return new ConfigManager(new DirectoryLoader($directory, $this->container), $strict); |
@@ -30,7 +30,8 @@ |
||
| 30 | 30 | |
| 31 | 31 | protected function getFactory(string $directory = null, bool $strict = true): ConfigManager |
| 32 | 32 | { |
| 33 | - if (is_null($directory)) { |
|
| 33 | + if (is_null($directory)) |
|
| 34 | + { |
|
| 34 | 35 | $directory = __DIR__ . '/fixtures'; |
| 35 | 36 | } |
| 36 | 37 | |
@@ -45,7 +45,7 @@ discard block |
||
| 45 | 45 | */ |
| 46 | 46 | public function __destruct() |
| 47 | 47 | { |
| 48 | - foreach ($this->destructFiles as $filename) { |
|
| 48 | + foreach ($this->destructFiles as $filename){ |
|
| 49 | 49 | $this->delete($filename); |
| 50 | 50 | } |
| 51 | 51 | } |
@@ -60,30 +60,30 @@ discard block |
||
| 60 | 60 | int $mode = null, |
| 61 | 61 | bool $recursivePermissions = true |
| 62 | 62 | ): bool { |
| 63 | - if (empty($mode)) { |
|
| 63 | + if (empty($mode)){ |
|
| 64 | 64 | $mode = self::DEFAULT_FILE_MODE; |
| 65 | 65 | } |
| 66 | 66 | |
| 67 | 67 | //Directories always executable |
| 68 | 68 | $mode = $mode | 0111; |
| 69 | - if (is_dir($directory)) { |
|
| 69 | + if (is_dir($directory)){ |
|
| 70 | 70 | //Exists :( |
| 71 | 71 | return $this->setPermissions($directory, $mode); |
| 72 | 72 | } |
| 73 | 73 | |
| 74 | - if (!$recursivePermissions) { |
|
| 74 | + if (!$recursivePermissions){ |
|
| 75 | 75 | return mkdir($directory, $mode, true); |
| 76 | 76 | } |
| 77 | 77 | |
| 78 | 78 | $directoryChain = [basename($directory)]; |
| 79 | 79 | |
| 80 | 80 | $baseDirectory = $directory; |
| 81 | - while (!is_dir($baseDirectory = dirname($baseDirectory))) { |
|
| 81 | + while (!is_dir($baseDirectory = dirname($baseDirectory))){ |
|
| 82 | 82 | $directoryChain[] = basename($baseDirectory); |
| 83 | 83 | } |
| 84 | 84 | |
| 85 | - foreach (array_reverse($directoryChain) as $directory) { |
|
| 86 | - if (!mkdir($baseDirectory = "{$baseDirectory}/{$directory}")) { |
|
| 85 | + foreach (array_reverse($directoryChain) as $directory){ |
|
| 86 | + if (!mkdir($baseDirectory = "{$baseDirectory}/{$directory}")){ |
|
| 87 | 87 | return false; |
| 88 | 88 | } |
| 89 | 89 | |
@@ -98,7 +98,7 @@ discard block |
||
| 98 | 98 | */ |
| 99 | 99 | public function read(string $filename): string |
| 100 | 100 | { |
| 101 | - if (!$this->exists($filename)) { |
|
| 101 | + if (!$this->exists($filename)){ |
|
| 102 | 102 | throw new FileNotFoundException($filename); |
| 103 | 103 | } |
| 104 | 104 | |
@@ -119,12 +119,12 @@ discard block |
||
| 119 | 119 | ): bool { |
| 120 | 120 | $mode = $mode ?? self::DEFAULT_FILE_MODE; |
| 121 | 121 | |
| 122 | - try { |
|
| 123 | - if ($ensureDirectory) { |
|
| 122 | + try{ |
|
| 123 | + if ($ensureDirectory){ |
|
| 124 | 124 | $this->ensureDirectory(dirname($filename), $mode); |
| 125 | 125 | } |
| 126 | 126 | |
| 127 | - if ($this->exists($filename)) { |
|
| 127 | + if ($this->exists($filename)){ |
|
| 128 | 128 | //Forcing mode for existed file |
| 129 | 129 | $this->setPermissions($filename, $mode); |
| 130 | 130 | } |
@@ -135,11 +135,11 @@ discard block |
||
| 135 | 135 | $append ? FILE_APPEND | LOCK_EX : LOCK_EX |
| 136 | 136 | ); |
| 137 | 137 | |
| 138 | - if ($result !== false) { |
|
| 138 | + if ($result !== false){ |
|
| 139 | 139 | //Forcing mode after file creation |
| 140 | 140 | $this->setPermissions($filename, $mode); |
| 141 | 141 | } |
| 142 | - } catch (\Exception $e) { |
|
| 142 | + }catch (\Exception $e){ |
|
| 143 | 143 | throw new WriteErrorException($e->getMessage(), $e->getCode(), $e); |
| 144 | 144 | } |
| 145 | 145 | |
@@ -163,7 +163,7 @@ discard block |
||
| 163 | 163 | */ |
| 164 | 164 | public function delete(string $filename) |
| 165 | 165 | { |
| 166 | - if ($this->exists($filename)) { |
|
| 166 | + if ($this->exists($filename)){ |
|
| 167 | 167 | $result = unlink($filename); |
| 168 | 168 | |
| 169 | 169 | //Wiping out changes in local file cache |
@@ -187,7 +187,7 @@ discard block |
||
| 187 | 187 | */ |
| 188 | 188 | public function deleteDirectory(string $directory, bool $contentOnly = false): void |
| 189 | 189 | { |
| 190 | - if (!$this->isDirectory($directory)) { |
|
| 190 | + if (!$this->isDirectory($directory)){ |
|
| 191 | 191 | throw new FilesException("Undefined or invalid directory {$directory}"); |
| 192 | 192 | } |
| 193 | 193 | |
@@ -196,15 +196,15 @@ discard block |
||
| 196 | 196 | \RecursiveIteratorIterator::CHILD_FIRST |
| 197 | 197 | ); |
| 198 | 198 | |
| 199 | - foreach ($files as $file) { |
|
| 200 | - if ($file->isDir()) { |
|
| 199 | + foreach ($files as $file){ |
|
| 200 | + if ($file->isDir()){ |
|
| 201 | 201 | rmdir($file->getRealPath()); |
| 202 | - } else { |
|
| 202 | + }else{ |
|
| 203 | 203 | $this->delete($file->getRealPath()); |
| 204 | 204 | } |
| 205 | 205 | } |
| 206 | 206 | |
| 207 | - if (!$contentOnly) { |
|
| 207 | + if (!$contentOnly){ |
|
| 208 | 208 | rmdir($directory); |
| 209 | 209 | } |
| 210 | 210 | } |
@@ -214,7 +214,7 @@ discard block |
||
| 214 | 214 | */ |
| 215 | 215 | public function move(string $filename, string $destination): bool |
| 216 | 216 | { |
| 217 | - if (!$this->exists($filename)) { |
|
| 217 | + if (!$this->exists($filename)){ |
|
| 218 | 218 | throw new FileNotFoundException($filename); |
| 219 | 219 | } |
| 220 | 220 | |
@@ -226,7 +226,7 @@ discard block |
||
| 226 | 226 | */ |
| 227 | 227 | public function copy(string $filename, string $destination): bool |
| 228 | 228 | { |
| 229 | - if (!$this->exists($filename)) { |
|
| 229 | + if (!$this->exists($filename)){ |
|
| 230 | 230 | throw new FileNotFoundException($filename); |
| 231 | 231 | } |
| 232 | 232 | |
@@ -238,7 +238,7 @@ discard block |
||
| 238 | 238 | */ |
| 239 | 239 | public function touch(string $filename, int $mode = null): bool |
| 240 | 240 | { |
| 241 | - if (!touch($filename)) { |
|
| 241 | + if (!touch($filename)){ |
|
| 242 | 242 | return false; |
| 243 | 243 | } |
| 244 | 244 | |
@@ -258,7 +258,7 @@ discard block |
||
| 258 | 258 | */ |
| 259 | 259 | public function size(string $filename): int |
| 260 | 260 | { |
| 261 | - if (!$this->exists($filename)) { |
|
| 261 | + if (!$this->exists($filename)){ |
|
| 262 | 262 | throw new FileNotFoundException($filename); |
| 263 | 263 | } |
| 264 | 264 | |
@@ -278,7 +278,7 @@ discard block |
||
| 278 | 278 | */ |
| 279 | 279 | public function md5(string $filename): string |
| 280 | 280 | { |
| 281 | - if (!$this->exists($filename)) { |
|
| 281 | + if (!$this->exists($filename)){ |
|
| 282 | 282 | throw new FileNotFoundException($filename); |
| 283 | 283 | } |
| 284 | 284 | |
@@ -290,7 +290,7 @@ discard block |
||
| 290 | 290 | */ |
| 291 | 291 | public function time(string $filename): int |
| 292 | 292 | { |
| 293 | - if (!$this->exists($filename)) { |
|
| 293 | + if (!$this->exists($filename)){ |
|
| 294 | 294 | throw new FileNotFoundException($filename); |
| 295 | 295 | } |
| 296 | 296 | |
@@ -318,7 +318,7 @@ discard block |
||
| 318 | 318 | */ |
| 319 | 319 | public function getPermissions(string $filename): int |
| 320 | 320 | { |
| 321 | - if (!$this->exists($filename)) { |
|
| 321 | + if (!$this->exists($filename)){ |
|
| 322 | 322 | throw new FileNotFoundException($filename); |
| 323 | 323 | } |
| 324 | 324 | |
@@ -330,7 +330,7 @@ discard block |
||
| 330 | 330 | */ |
| 331 | 331 | public function setPermissions(string $filename, int $mode) |
| 332 | 332 | { |
| 333 | - if (is_dir($filename)) { |
|
| 333 | + if (is_dir($filename)){ |
|
| 334 | 334 | //Directories must always be executable (i.e. 664 for dir => 775) |
| 335 | 335 | $mode |= 0111; |
| 336 | 336 | } |
@@ -344,9 +344,9 @@ discard block |
||
| 344 | 344 | public function getFiles(string $location, string $pattern = null): array |
| 345 | 345 | { |
| 346 | 346 | $result = []; |
| 347 | - foreach ($this->filesIterator($location, $pattern) as $filename) { |
|
| 348 | - if ($this->isDirectory($filename->getPathname())) { |
|
| 349 | - $result = array_merge($result, $this->getFiles($filename . DIRECTORY_SEPARATOR)); |
|
| 347 | + foreach ($this->filesIterator($location, $pattern) as $filename){ |
|
| 348 | + if ($this->isDirectory($filename->getPathname())){ |
|
| 349 | + $result = array_merge($result, $this->getFiles($filename.DIRECTORY_SEPARATOR)); |
|
| 350 | 350 | |
| 351 | 351 | continue; |
| 352 | 352 | } |
@@ -362,13 +362,13 @@ discard block |
||
| 362 | 362 | */ |
| 363 | 363 | public function tempFilename(string $extension = '', string $location = null): string |
| 364 | 364 | { |
| 365 | - if (empty($location)) { |
|
| 365 | + if (empty($location)){ |
|
| 366 | 366 | $location = sys_get_temp_dir(); |
| 367 | 367 | } |
| 368 | 368 | |
| 369 | 369 | $filename = tempnam($location, 'spiral'); |
| 370 | 370 | |
| 371 | - if (!empty($extension)) { |
|
| 371 | + if (!empty($extension)){ |
|
| 372 | 372 | //I should find more original way of doing that |
| 373 | 373 | rename($filename, $filename = "{$filename}.{$extension}"); |
| 374 | 374 | $this->destructFiles[] = $filename; |
@@ -385,7 +385,7 @@ discard block |
||
| 385 | 385 | $path = str_replace(['//', '\\'], '/', $path); |
| 386 | 386 | |
| 387 | 387 | //Potentially open links and ../ type directories? |
| 388 | - return rtrim($path, '/') . ($asDirectory ? '/' : ''); |
|
| 388 | + return rtrim($path, '/').($asDirectory ? '/' : ''); |
|
| 389 | 389 | } |
| 390 | 390 | |
| 391 | 391 | /** |
@@ -402,21 +402,21 @@ discard block |
||
| 402 | 402 | $path = explode('/', $path); |
| 403 | 403 | $relative = $path; |
| 404 | 404 | |
| 405 | - foreach ($from as $depth => $dir) { |
|
| 405 | + foreach ($from as $depth => $dir){ |
|
| 406 | 406 | //Find first non-matching dir |
| 407 | - if ($dir === $path[$depth]) { |
|
| 407 | + if ($dir === $path[$depth]){ |
|
| 408 | 408 | //Ignore this directory |
| 409 | 409 | array_shift($relative); |
| 410 | - } else { |
|
| 410 | + }else{ |
|
| 411 | 411 | //Get number of remaining dirs to $from |
| 412 | 412 | $remaining = count($from) - $depth; |
| 413 | - if ($remaining > 1) { |
|
| 413 | + if ($remaining > 1){ |
|
| 414 | 414 | //Add traversals up to first matching directory |
| 415 | 415 | $padLength = (count($relative) + $remaining - 1) * -1; |
| 416 | 416 | $relative = array_pad($relative, $padLength, '..'); |
| 417 | 417 | break; |
| 418 | 418 | } |
| 419 | - $relative[0] = './' . $relative[0]; |
|
| 419 | + $relative[0] = './'.$relative[0]; |
|
| 420 | 420 | } |
| 421 | 421 | } |
| 422 | 422 | |
@@ -432,7 +432,7 @@ discard block |
||
| 432 | 432 | private function filesIterator(string $location, string $pattern = null): \GlobIterator |
| 433 | 433 | { |
| 434 | 434 | $pattern = $pattern ?? '*'; |
| 435 | - $regexp = rtrim($location, DIRECTORY_SEPARATOR) . DIRECTORY_SEPARATOR . ltrim($pattern, DIRECTORY_SEPARATOR); |
|
| 435 | + $regexp = rtrim($location, DIRECTORY_SEPARATOR).DIRECTORY_SEPARATOR.ltrim($pattern, DIRECTORY_SEPARATOR); |
|
| 436 | 436 | |
| 437 | 437 | return new \GlobIterator($regexp); |
| 438 | 438 | } |
@@ -45,7 +45,8 @@ discard block |
||
| 45 | 45 | */ |
| 46 | 46 | public function __destruct() |
| 47 | 47 | { |
| 48 | - foreach ($this->destructFiles as $filename) { |
|
| 48 | + foreach ($this->destructFiles as $filename) |
|
| 49 | + { |
|
| 49 | 50 | $this->delete($filename); |
| 50 | 51 | } |
| 51 | 52 | } |
@@ -60,30 +61,36 @@ discard block |
||
| 60 | 61 | int $mode = null, |
| 61 | 62 | bool $recursivePermissions = true |
| 62 | 63 | ): bool { |
| 63 | - if (empty($mode)) { |
|
| 64 | + if (empty($mode)) |
|
| 65 | + { |
|
| 64 | 66 | $mode = self::DEFAULT_FILE_MODE; |
| 65 | 67 | } |
| 66 | 68 | |
| 67 | 69 | //Directories always executable |
| 68 | 70 | $mode = $mode | 0111; |
| 69 | - if (is_dir($directory)) { |
|
| 71 | + if (is_dir($directory)) |
|
| 72 | + { |
|
| 70 | 73 | //Exists :( |
| 71 | 74 | return $this->setPermissions($directory, $mode); |
| 72 | 75 | } |
| 73 | 76 | |
| 74 | - if (!$recursivePermissions) { |
|
| 77 | + if (!$recursivePermissions) |
|
| 78 | + { |
|
| 75 | 79 | return mkdir($directory, $mode, true); |
| 76 | 80 | } |
| 77 | 81 | |
| 78 | 82 | $directoryChain = [basename($directory)]; |
| 79 | 83 | |
| 80 | 84 | $baseDirectory = $directory; |
| 81 | - while (!is_dir($baseDirectory = dirname($baseDirectory))) { |
|
| 85 | + while (!is_dir($baseDirectory = dirname($baseDirectory))) |
|
| 86 | + { |
|
| 82 | 87 | $directoryChain[] = basename($baseDirectory); |
| 83 | 88 | } |
| 84 | 89 | |
| 85 | - foreach (array_reverse($directoryChain) as $directory) { |
|
| 86 | - if (!mkdir($baseDirectory = "{$baseDirectory}/{$directory}")) { |
|
| 90 | + foreach (array_reverse($directoryChain) as $directory) |
|
| 91 | + { |
|
| 92 | + if (!mkdir($baseDirectory = "{$baseDirectory}/{$directory}")) |
|
| 93 | + { |
|
| 87 | 94 | return false; |
| 88 | 95 | } |
| 89 | 96 | |
@@ -98,7 +105,8 @@ discard block |
||
| 98 | 105 | */ |
| 99 | 106 | public function read(string $filename): string |
| 100 | 107 | { |
| 101 | - if (!$this->exists($filename)) { |
|
| 108 | + if (!$this->exists($filename)) |
|
| 109 | + { |
|
| 102 | 110 | throw new FileNotFoundException($filename); |
| 103 | 111 | } |
| 104 | 112 | |
@@ -119,12 +127,15 @@ discard block |
||
| 119 | 127 | ): bool { |
| 120 | 128 | $mode = $mode ?? self::DEFAULT_FILE_MODE; |
| 121 | 129 | |
| 122 | - try { |
|
| 123 | - if ($ensureDirectory) { |
|
| 130 | + try |
|
| 131 | + { |
|
| 132 | + if ($ensureDirectory) |
|
| 133 | + { |
|
| 124 | 134 | $this->ensureDirectory(dirname($filename), $mode); |
| 125 | 135 | } |
| 126 | 136 | |
| 127 | - if ($this->exists($filename)) { |
|
| 137 | + if ($this->exists($filename)) |
|
| 138 | + { |
|
| 128 | 139 | //Forcing mode for existed file |
| 129 | 140 | $this->setPermissions($filename, $mode); |
| 130 | 141 | } |
@@ -135,11 +146,14 @@ discard block |
||
| 135 | 146 | $append ? FILE_APPEND | LOCK_EX : LOCK_EX |
| 136 | 147 | ); |
| 137 | 148 | |
| 138 | - if ($result !== false) { |
|
| 149 | + if ($result !== false) |
|
| 150 | + { |
|
| 139 | 151 | //Forcing mode after file creation |
| 140 | 152 | $this->setPermissions($filename, $mode); |
| 141 | 153 | } |
| 142 | - } catch (\Exception $e) { |
|
| 154 | + } |
|
| 155 | + catch (\Exception $e) |
|
| 156 | + { |
|
| 143 | 157 | throw new WriteErrorException($e->getMessage(), $e->getCode(), $e); |
| 144 | 158 | } |
| 145 | 159 | |
@@ -163,7 +177,8 @@ discard block |
||
| 163 | 177 | */ |
| 164 | 178 | public function delete(string $filename) |
| 165 | 179 | { |
| 166 | - if ($this->exists($filename)) { |
|
| 180 | + if ($this->exists($filename)) |
|
| 181 | + { |
|
| 167 | 182 | $result = unlink($filename); |
| 168 | 183 | |
| 169 | 184 | //Wiping out changes in local file cache |
@@ -187,7 +202,8 @@ discard block |
||
| 187 | 202 | */ |
| 188 | 203 | public function deleteDirectory(string $directory, bool $contentOnly = false): void |
| 189 | 204 | { |
| 190 | - if (!$this->isDirectory($directory)) { |
|
| 205 | + if (!$this->isDirectory($directory)) |
|
| 206 | + { |
|
| 191 | 207 | throw new FilesException("Undefined or invalid directory {$directory}"); |
| 192 | 208 | } |
| 193 | 209 | |
@@ -196,15 +212,20 @@ discard block |
||
| 196 | 212 | \RecursiveIteratorIterator::CHILD_FIRST |
| 197 | 213 | ); |
| 198 | 214 | |
| 199 | - foreach ($files as $file) { |
|
| 200 | - if ($file->isDir()) { |
|
| 215 | + foreach ($files as $file) |
|
| 216 | + { |
|
| 217 | + if ($file->isDir()) |
|
| 218 | + { |
|
| 201 | 219 | rmdir($file->getRealPath()); |
| 202 | - } else { |
|
| 220 | + } |
|
| 221 | + else |
|
| 222 | + { |
|
| 203 | 223 | $this->delete($file->getRealPath()); |
| 204 | 224 | } |
| 205 | 225 | } |
| 206 | 226 | |
| 207 | - if (!$contentOnly) { |
|
| 227 | + if (!$contentOnly) |
|
| 228 | + { |
|
| 208 | 229 | rmdir($directory); |
| 209 | 230 | } |
| 210 | 231 | } |
@@ -214,7 +235,8 @@ discard block |
||
| 214 | 235 | */ |
| 215 | 236 | public function move(string $filename, string $destination): bool |
| 216 | 237 | { |
| 217 | - if (!$this->exists($filename)) { |
|
| 238 | + if (!$this->exists($filename)) |
|
| 239 | + { |
|
| 218 | 240 | throw new FileNotFoundException($filename); |
| 219 | 241 | } |
| 220 | 242 | |
@@ -226,7 +248,8 @@ discard block |
||
| 226 | 248 | */ |
| 227 | 249 | public function copy(string $filename, string $destination): bool |
| 228 | 250 | { |
| 229 | - if (!$this->exists($filename)) { |
|
| 251 | + if (!$this->exists($filename)) |
|
| 252 | + { |
|
| 230 | 253 | throw new FileNotFoundException($filename); |
| 231 | 254 | } |
| 232 | 255 | |
@@ -238,7 +261,8 @@ discard block |
||
| 238 | 261 | */ |
| 239 | 262 | public function touch(string $filename, int $mode = null): bool |
| 240 | 263 | { |
| 241 | - if (!touch($filename)) { |
|
| 264 | + if (!touch($filename)) |
|
| 265 | + { |
|
| 242 | 266 | return false; |
| 243 | 267 | } |
| 244 | 268 | |
@@ -258,7 +282,8 @@ discard block |
||
| 258 | 282 | */ |
| 259 | 283 | public function size(string $filename): int |
| 260 | 284 | { |
| 261 | - if (!$this->exists($filename)) { |
|
| 285 | + if (!$this->exists($filename)) |
|
| 286 | + { |
|
| 262 | 287 | throw new FileNotFoundException($filename); |
| 263 | 288 | } |
| 264 | 289 | |
@@ -278,7 +303,8 @@ discard block |
||
| 278 | 303 | */ |
| 279 | 304 | public function md5(string $filename): string |
| 280 | 305 | { |
| 281 | - if (!$this->exists($filename)) { |
|
| 306 | + if (!$this->exists($filename)) |
|
| 307 | + { |
|
| 282 | 308 | throw new FileNotFoundException($filename); |
| 283 | 309 | } |
| 284 | 310 | |
@@ -290,7 +316,8 @@ discard block |
||
| 290 | 316 | */ |
| 291 | 317 | public function time(string $filename): int |
| 292 | 318 | { |
| 293 | - if (!$this->exists($filename)) { |
|
| 319 | + if (!$this->exists($filename)) |
|
| 320 | + { |
|
| 294 | 321 | throw new FileNotFoundException($filename); |
| 295 | 322 | } |
| 296 | 323 | |
@@ -318,7 +345,8 @@ discard block |
||
| 318 | 345 | */ |
| 319 | 346 | public function getPermissions(string $filename): int |
| 320 | 347 | { |
| 321 | - if (!$this->exists($filename)) { |
|
| 348 | + if (!$this->exists($filename)) |
|
| 349 | + { |
|
| 322 | 350 | throw new FileNotFoundException($filename); |
| 323 | 351 | } |
| 324 | 352 | |
@@ -330,7 +358,8 @@ discard block |
||
| 330 | 358 | */ |
| 331 | 359 | public function setPermissions(string $filename, int $mode) |
| 332 | 360 | { |
| 333 | - if (is_dir($filename)) { |
|
| 361 | + if (is_dir($filename)) |
|
| 362 | + { |
|
| 334 | 363 | //Directories must always be executable (i.e. 664 for dir => 775) |
| 335 | 364 | $mode |= 0111; |
| 336 | 365 | } |
@@ -344,8 +373,10 @@ discard block |
||
| 344 | 373 | public function getFiles(string $location, string $pattern = null): array |
| 345 | 374 | { |
| 346 | 375 | $result = []; |
| 347 | - foreach ($this->filesIterator($location, $pattern) as $filename) { |
|
| 348 | - if ($this->isDirectory($filename->getPathname())) { |
|
| 376 | + foreach ($this->filesIterator($location, $pattern) as $filename) |
|
| 377 | + { |
|
| 378 | + if ($this->isDirectory($filename->getPathname())) |
|
| 379 | + { |
|
| 349 | 380 | $result = array_merge($result, $this->getFiles($filename . DIRECTORY_SEPARATOR)); |
| 350 | 381 | |
| 351 | 382 | continue; |
@@ -362,13 +393,15 @@ discard block |
||
| 362 | 393 | */ |
| 363 | 394 | public function tempFilename(string $extension = '', string $location = null): string |
| 364 | 395 | { |
| 365 | - if (empty($location)) { |
|
| 396 | + if (empty($location)) |
|
| 397 | + { |
|
| 366 | 398 | $location = sys_get_temp_dir(); |
| 367 | 399 | } |
| 368 | 400 | |
| 369 | 401 | $filename = tempnam($location, 'spiral'); |
| 370 | 402 | |
| 371 | - if (!empty($extension)) { |
|
| 403 | + if (!empty($extension)) |
|
| 404 | + { |
|
| 372 | 405 | //I should find more original way of doing that |
| 373 | 406 | rename($filename, $filename = "{$filename}.{$extension}"); |
| 374 | 407 | $this->destructFiles[] = $filename; |
@@ -402,15 +435,20 @@ discard block |
||
| 402 | 435 | $path = explode('/', $path); |
| 403 | 436 | $relative = $path; |
| 404 | 437 | |
| 405 | - foreach ($from as $depth => $dir) { |
|
| 438 | + foreach ($from as $depth => $dir) |
|
| 439 | + { |
|
| 406 | 440 | //Find first non-matching dir |
| 407 | - if ($dir === $path[$depth]) { |
|
| 441 | + if ($dir === $path[$depth]) |
|
| 442 | + { |
|
| 408 | 443 | //Ignore this directory |
| 409 | 444 | array_shift($relative); |
| 410 | - } else { |
|
| 445 | + } |
|
| 446 | + else |
|
| 447 | + { |
|
| 411 | 448 | //Get number of remaining dirs to $from |
| 412 | 449 | $remaining = count($from) - $depth; |
| 413 | - if ($remaining > 1) { |
|
| 450 | + if ($remaining > 1) |
|
| 451 | + { |
|
| 414 | 452 | //Add traversals up to first matching directory |
| 415 | 453 | $padLength = (count($relative) + $remaining - 1) * -1; |
| 416 | 454 | $relative = array_pad($relative, $padLength, '..'); |
@@ -32,7 +32,7 @@ discard block |
||
| 32 | 32 | public function testEnsureDirectory(): void |
| 33 | 33 | { |
| 34 | 34 | $files = new Files(); |
| 35 | - $directory = self::FIXTURE_DIRECTORY . 'directory/'; |
|
| 35 | + $directory = self::FIXTURE_DIRECTORY.'directory/'; |
|
| 36 | 36 | |
| 37 | 37 | $this->assertFalse($files->exists($directory)); |
| 38 | 38 | $this->assertFalse($files->isDirectory($directory)); |
@@ -46,7 +46,7 @@ discard block |
||
| 46 | 46 | public function testEnsureExistedDirectory(): void |
| 47 | 47 | { |
| 48 | 48 | $files = new Files(); |
| 49 | - $directory = self::FIXTURE_DIRECTORY . 'directory/'; |
|
| 49 | + $directory = self::FIXTURE_DIRECTORY.'directory/'; |
|
| 50 | 50 | |
| 51 | 51 | $this->assertFalse($files->exists($directory)); |
| 52 | 52 | $this->assertFalse($files->isDirectory($directory)); |
@@ -65,7 +65,7 @@ discard block |
||
| 65 | 65 | public function testEnsureNestedDirectory(): void |
| 66 | 66 | { |
| 67 | 67 | $files = new Files(); |
| 68 | - $directory = self::FIXTURE_DIRECTORY . 'directory/sub/other'; |
|
| 68 | + $directory = self::FIXTURE_DIRECTORY.'directory/sub/other'; |
|
| 69 | 69 | |
| 70 | 70 | $this->assertFalse($files->exists($directory)); |
| 71 | 71 | $this->assertFalse($files->isDirectory($directory)); |
@@ -79,7 +79,7 @@ discard block |
||
| 79 | 79 | public function testEnsureNestedDirectoryNoRecursivePermissions(): void |
| 80 | 80 | { |
| 81 | 81 | $files = new Files(); |
| 82 | - $directory = self::FIXTURE_DIRECTORY . 'directory/sub/other'; |
|
| 82 | + $directory = self::FIXTURE_DIRECTORY.'directory/sub/other'; |
|
| 83 | 83 | |
| 84 | 84 | $this->assertFalse($files->exists($directory)); |
| 85 | 85 | $this->assertFalse($files->isDirectory($directory)); |
@@ -93,14 +93,14 @@ discard block |
||
| 93 | 93 | public function testEnsureExistedNestedDirectory(): void |
| 94 | 94 | { |
| 95 | 95 | $files = new Files(); |
| 96 | - $directory = self::FIXTURE_DIRECTORY . 'directory/sub/other'; |
|
| 96 | + $directory = self::FIXTURE_DIRECTORY.'directory/sub/other'; |
|
| 97 | 97 | |
| 98 | 98 | $this->assertFalse($files->exists($directory)); |
| 99 | 99 | $this->assertFalse($files->isDirectory($directory)); |
| 100 | 100 | |
| 101 | - mkdir(self::FIXTURE_DIRECTORY . 'directory'); |
|
| 102 | - mkdir(self::FIXTURE_DIRECTORY . 'directory/sub'); |
|
| 103 | - mkdir(self::FIXTURE_DIRECTORY . 'directory/sub/other'); |
|
| 101 | + mkdir(self::FIXTURE_DIRECTORY.'directory'); |
|
| 102 | + mkdir(self::FIXTURE_DIRECTORY.'directory/sub'); |
|
| 103 | + mkdir(self::FIXTURE_DIRECTORY.'directory/sub/other'); |
|
| 104 | 104 | |
| 105 | 105 | $this->assertTrue($files->exists($directory)); |
| 106 | 106 | $this->assertTrue($files->isDirectory($directory)); |
@@ -114,13 +114,13 @@ discard block |
||
| 114 | 114 | public function testDeleteDirectoryContent(): void |
| 115 | 115 | { |
| 116 | 116 | $files = new Files(); |
| 117 | - $baseDirectory = self::FIXTURE_DIRECTORY . 'directory/'; |
|
| 118 | - $directory = $baseDirectory . 'sub/other'; |
|
| 117 | + $baseDirectory = self::FIXTURE_DIRECTORY.'directory/'; |
|
| 118 | + $directory = $baseDirectory.'sub/other'; |
|
| 119 | 119 | |
| 120 | 120 | $filenames = [ |
| 121 | - $baseDirectory . 'test.file', |
|
| 122 | - $directory . 'other.file', |
|
| 123 | - $directory . '.sample', |
|
| 121 | + $baseDirectory.'test.file', |
|
| 122 | + $directory.'other.file', |
|
| 123 | + $directory.'.sample', |
|
| 124 | 124 | ]; |
| 125 | 125 | |
| 126 | 126 | $this->assertFalse($files->exists($baseDirectory)); |
@@ -137,7 +137,7 @@ discard block |
||
| 137 | 137 | $this->assertTrue($files->exists($directory)); |
| 138 | 138 | $this->assertTrue($files->isDirectory($directory)); |
| 139 | 139 | |
| 140 | - foreach ($filenames as $filename) { |
|
| 140 | + foreach ($filenames as $filename){ |
|
| 141 | 141 | $this->assertFalse($files->exists($filename)); |
| 142 | 142 | $files->write($filename, 'random-data'); |
| 143 | 143 | $this->assertTrue($files->exists($filename)); |
@@ -151,7 +151,7 @@ discard block |
||
| 151 | 151 | $this->assertFalse($files->exists($directory)); |
| 152 | 152 | $this->assertFalse($files->isDirectory($directory)); |
| 153 | 153 | |
| 154 | - foreach ($filenames as $filename) { |
|
| 154 | + foreach ($filenames as $filename){ |
|
| 155 | 155 | $this->assertFalse($files->exists($filename)); |
| 156 | 156 | } |
| 157 | 157 | } |
@@ -159,13 +159,13 @@ discard block |
||
| 159 | 159 | public function testDeleteDirectory(): void |
| 160 | 160 | { |
| 161 | 161 | $files = new Files(); |
| 162 | - $baseDirectory = self::FIXTURE_DIRECTORY . 'directory/'; |
|
| 163 | - $directory = $baseDirectory . 'sub/other'; |
|
| 162 | + $baseDirectory = self::FIXTURE_DIRECTORY.'directory/'; |
|
| 163 | + $directory = $baseDirectory.'sub/other'; |
|
| 164 | 164 | |
| 165 | 165 | $filenames = [ |
| 166 | - $baseDirectory . 'test.file', |
|
| 167 | - $directory . 'other.file', |
|
| 168 | - $directory . '.sample', |
|
| 166 | + $baseDirectory.'test.file', |
|
| 167 | + $directory.'other.file', |
|
| 168 | + $directory.'.sample', |
|
| 169 | 169 | ]; |
| 170 | 170 | |
| 171 | 171 | $this->assertFalse($files->exists($baseDirectory)); |
@@ -182,7 +182,7 @@ discard block |
||
| 182 | 182 | $this->assertTrue($files->exists($directory)); |
| 183 | 183 | $this->assertTrue($files->isDirectory($directory)); |
| 184 | 184 | |
| 185 | - foreach ($filenames as $filename) { |
|
| 185 | + foreach ($filenames as $filename){ |
|
| 186 | 186 | $this->assertFalse($files->exists($filename)); |
| 187 | 187 | $files->write($filename, 'random-data'); |
| 188 | 188 | $this->assertTrue($files->exists($filename)); |
@@ -196,7 +196,7 @@ discard block |
||
| 196 | 196 | $this->assertFalse($files->exists($directory)); |
| 197 | 197 | $this->assertFalse($files->isDirectory($directory)); |
| 198 | 198 | |
| 199 | - foreach ($filenames as $filename) { |
|
| 199 | + foreach ($filenames as $filename){ |
|
| 200 | 200 | $this->assertFalse($files->exists($filename)); |
| 201 | 201 | } |
| 202 | 202 | } |
@@ -207,8 +207,8 @@ discard block |
||
| 207 | 207 | |
| 208 | 208 | $files = new Files(); |
| 209 | 209 | |
| 210 | - $files->write(self::FIXTURE_DIRECTORY . 'test', 'data'); |
|
| 211 | - $files->deleteDirectory(self::FIXTURE_DIRECTORY . 'test'); |
|
| 210 | + $files->write(self::FIXTURE_DIRECTORY.'test', 'data'); |
|
| 211 | + $files->deleteDirectory(self::FIXTURE_DIRECTORY.'test'); |
|
| 212 | 212 | } |
| 213 | 213 | |
| 214 | 214 | public function testGetFiles(): void |
@@ -137,7 +137,8 @@ discard block |
||
| 137 | 137 | $this->assertTrue($files->exists($directory)); |
| 138 | 138 | $this->assertTrue($files->isDirectory($directory)); |
| 139 | 139 | |
| 140 | - foreach ($filenames as $filename) { |
|
| 140 | + foreach ($filenames as $filename) |
|
| 141 | + { |
|
| 141 | 142 | $this->assertFalse($files->exists($filename)); |
| 142 | 143 | $files->write($filename, 'random-data'); |
| 143 | 144 | $this->assertTrue($files->exists($filename)); |
@@ -151,7 +152,8 @@ discard block |
||
| 151 | 152 | $this->assertFalse($files->exists($directory)); |
| 152 | 153 | $this->assertFalse($files->isDirectory($directory)); |
| 153 | 154 | |
| 154 | - foreach ($filenames as $filename) { |
|
| 155 | + foreach ($filenames as $filename) |
|
| 156 | + { |
|
| 155 | 157 | $this->assertFalse($files->exists($filename)); |
| 156 | 158 | } |
| 157 | 159 | } |
@@ -182,7 +184,8 @@ discard block |
||
| 182 | 184 | $this->assertTrue($files->exists($directory)); |
| 183 | 185 | $this->assertTrue($files->isDirectory($directory)); |
| 184 | 186 | |
| 185 | - foreach ($filenames as $filename) { |
|
| 187 | + foreach ($filenames as $filename) |
|
| 188 | + { |
|
| 186 | 189 | $this->assertFalse($files->exists($filename)); |
| 187 | 190 | $files->write($filename, 'random-data'); |
| 188 | 191 | $this->assertTrue($files->exists($filename)); |
@@ -196,7 +199,8 @@ discard block |
||
| 196 | 199 | $this->assertFalse($files->exists($directory)); |
| 197 | 200 | $this->assertFalse($files->isDirectory($directory)); |
| 198 | 201 | |
| 199 | - foreach ($filenames as $filename) { |
|
| 202 | + foreach ($filenames as $filename) |
|
| 203 | + { |
|
| 200 | 204 | $this->assertFalse($files->exists($filename)); |
| 201 | 205 | } |
| 202 | 206 | } |
@@ -34,7 +34,7 @@ discard block |
||
| 34 | 34 | { |
| 35 | 35 | $files = new Files(); |
| 36 | 36 | |
| 37 | - $filename = self::FIXTURE_DIRECTORY . '/test.txt'; |
|
| 37 | + $filename = self::FIXTURE_DIRECTORY.'/test.txt'; |
|
| 38 | 38 | $this->assertFalse($files->exists($filename)); |
| 39 | 39 | |
| 40 | 40 | $files->write($filename, 'some-data'); |
@@ -47,8 +47,8 @@ discard block |
||
| 47 | 47 | { |
| 48 | 48 | $files = new Files(); |
| 49 | 49 | |
| 50 | - $directory = self::FIXTURE_DIRECTORY . '/directory/abc/'; |
|
| 51 | - $filename = $directory . 'test.txt'; |
|
| 50 | + $directory = self::FIXTURE_DIRECTORY.'/directory/abc/'; |
|
| 51 | + $filename = $directory.'test.txt'; |
|
| 52 | 52 | |
| 53 | 53 | $this->assertFalse($files->exists($directory)); |
| 54 | 54 | $this->assertFalse($files->exists($filename)); |
@@ -66,7 +66,7 @@ discard block |
||
| 66 | 66 | { |
| 67 | 67 | $files = new Files(); |
| 68 | 68 | |
| 69 | - $filename = self::FIXTURE_DIRECTORY . '/test.txt'; |
|
| 69 | + $filename = self::FIXTURE_DIRECTORY.'/test.txt'; |
|
| 70 | 70 | $this->assertFalse($files->exists($filename)); |
| 71 | 71 | |
| 72 | 72 | $files->write($filename, 'some-data'); |
@@ -82,7 +82,7 @@ discard block |
||
| 82 | 82 | |
| 83 | 83 | $files = new Files(); |
| 84 | 84 | |
| 85 | - $filename = self::FIXTURE_DIRECTORY . '/test.txt'; |
|
| 85 | + $filename = self::FIXTURE_DIRECTORY.'/test.txt'; |
|
| 86 | 86 | $this->assertFalse($files->exists($filename)); |
| 87 | 87 | |
| 88 | 88 | $files->read($filename); |
@@ -101,14 +101,14 @@ discard block |
||
| 101 | 101 | $this->expectException(FileNotFoundException::class); |
| 102 | 102 | |
| 103 | 103 | $files = new Files(); |
| 104 | - $files->getPermissions(self::FIXTURE_DIRECTORY . '/missing'); |
|
| 104 | + $files->getPermissions(self::FIXTURE_DIRECTORY.'/missing'); |
|
| 105 | 105 | } |
| 106 | 106 | |
| 107 | 107 | public function testAppend(): void |
| 108 | 108 | { |
| 109 | 109 | $files = new Files(); |
| 110 | 110 | |
| 111 | - $filename = self::FIXTURE_DIRECTORY . '/test.txt'; |
|
| 111 | + $filename = self::FIXTURE_DIRECTORY.'/test.txt'; |
|
| 112 | 112 | $this->assertFalse($files->exists($filename)); |
| 113 | 113 | |
| 114 | 114 | $files->append($filename, 'some-data'); |
@@ -124,8 +124,8 @@ discard block |
||
| 124 | 124 | { |
| 125 | 125 | $files = new Files(); |
| 126 | 126 | |
| 127 | - $directory = self::FIXTURE_DIRECTORY . '/directory/abc/'; |
|
| 128 | - $filename = $directory . 'test.txt'; |
|
| 127 | + $directory = self::FIXTURE_DIRECTORY.'/directory/abc/'; |
|
| 128 | + $filename = $directory.'test.txt'; |
|
| 129 | 129 | |
| 130 | 130 | $this->assertFalse($files->exists($directory)); |
| 131 | 131 | $this->assertFalse($files->exists($filename)); |
@@ -146,7 +146,7 @@ discard block |
||
| 146 | 146 | { |
| 147 | 147 | $files = new Files(); |
| 148 | 148 | |
| 149 | - $filename = self::FIXTURE_DIRECTORY . '/test.txt'; |
|
| 149 | + $filename = self::FIXTURE_DIRECTORY.'/test.txt'; |
|
| 150 | 150 | |
| 151 | 151 | $this->assertFalse($files->exists($filename)); |
| 152 | 152 | $files->touch($filename); |
@@ -156,7 +156,7 @@ discard block |
||
| 156 | 156 | public function testDelete(): void |
| 157 | 157 | { |
| 158 | 158 | $files = new Files(); |
| 159 | - $filename = self::FIXTURE_DIRECTORY . '/test.txt'; |
|
| 159 | + $filename = self::FIXTURE_DIRECTORY.'/test.txt'; |
|
| 160 | 160 | |
| 161 | 161 | $this->assertFalse($files->exists($filename)); |
| 162 | 162 | |
@@ -170,7 +170,7 @@ discard block |
||
| 170 | 170 | public function testDeleteMissingFile(): void |
| 171 | 171 | { |
| 172 | 172 | $files = new Files(); |
| 173 | - $filename = self::FIXTURE_DIRECTORY . '/test.txt'; |
|
| 173 | + $filename = self::FIXTURE_DIRECTORY.'/test.txt'; |
|
| 174 | 174 | |
| 175 | 175 | $this->assertFalse($files->exists($filename)); |
| 176 | 176 | $files->delete($filename); |
@@ -179,8 +179,8 @@ discard block |
||
| 179 | 179 | public function testCopy(): void |
| 180 | 180 | { |
| 181 | 181 | $files = new Files(); |
| 182 | - $filename = self::FIXTURE_DIRECTORY . '/test.txt'; |
|
| 183 | - $destination = self::FIXTURE_DIRECTORY . '/new.txt'; |
|
| 182 | + $filename = self::FIXTURE_DIRECTORY.'/test.txt'; |
|
| 183 | + $destination = self::FIXTURE_DIRECTORY.'/new.txt'; |
|
| 184 | 184 | |
| 185 | 185 | $this->assertFalse($files->exists($filename)); |
| 186 | 186 | $files->write($filename, 'some-data'); |
@@ -203,8 +203,8 @@ discard block |
||
| 203 | 203 | $this->expectException(FileNotFoundException::class); |
| 204 | 204 | |
| 205 | 205 | $files = new Files(); |
| 206 | - $filename = self::FIXTURE_DIRECTORY . '/test.txt'; |
|
| 207 | - $destination = self::FIXTURE_DIRECTORY . '/new.txt'; |
|
| 206 | + $filename = self::FIXTURE_DIRECTORY.'/test.txt'; |
|
| 207 | + $destination = self::FIXTURE_DIRECTORY.'/new.txt'; |
|
| 208 | 208 | |
| 209 | 209 | $this->assertFalse($files->exists($filename)); |
| 210 | 210 | $files->copy($filename, $destination); |
@@ -213,8 +213,8 @@ discard block |
||
| 213 | 213 | public function testMove(): void |
| 214 | 214 | { |
| 215 | 215 | $files = new Files(); |
| 216 | - $filename = self::FIXTURE_DIRECTORY . '/test.txt'; |
|
| 217 | - $destination = self::FIXTURE_DIRECTORY . '/new.txt'; |
|
| 216 | + $filename = self::FIXTURE_DIRECTORY.'/test.txt'; |
|
| 217 | + $destination = self::FIXTURE_DIRECTORY.'/new.txt'; |
|
| 218 | 218 | |
| 219 | 219 | $this->assertFalse($files->exists($filename)); |
| 220 | 220 | $files->write($filename, 'some-data'); |
@@ -237,8 +237,8 @@ discard block |
||
| 237 | 237 | $this->expectException(FileNotFoundException::class); |
| 238 | 238 | |
| 239 | 239 | $files = new Files(); |
| 240 | - $filename = self::FIXTURE_DIRECTORY . '/test.txt'; |
|
| 241 | - $destination = self::FIXTURE_DIRECTORY . '/new.txt'; |
|
| 240 | + $filename = self::FIXTURE_DIRECTORY.'/test.txt'; |
|
| 241 | + $destination = self::FIXTURE_DIRECTORY.'/new.txt'; |
|
| 242 | 242 | |
| 243 | 243 | $this->assertFalse($files->exists($filename)); |
| 244 | 244 | $files->move($filename, $destination); |
@@ -32,7 +32,7 @@ discard block |
||
| 32 | 32 | public function testTime(): void |
| 33 | 33 | { |
| 34 | 34 | $files = new Files(); |
| 35 | - $filename = self::FIXTURE_DIRECTORY . '/test.txt'; |
|
| 35 | + $filename = self::FIXTURE_DIRECTORY.'/test.txt'; |
|
| 36 | 36 | |
| 37 | 37 | $files->write($filename, 'data', FilesInterface::READONLY); |
| 38 | 38 | $this->assertEquals(filemtime($filename), $files->time($filename)); |
@@ -44,7 +44,7 @@ discard block |
||
| 44 | 44 | $this->expectException(FileNotFoundException::class); |
| 45 | 45 | |
| 46 | 46 | $files = new Files(); |
| 47 | - $filename = self::FIXTURE_DIRECTORY . '/test.txt'; |
|
| 47 | + $filename = self::FIXTURE_DIRECTORY.'/test.txt'; |
|
| 48 | 48 | |
| 49 | 49 | $files->time($filename); |
| 50 | 50 | } |
@@ -52,7 +52,7 @@ discard block |
||
| 52 | 52 | public function testMD5(): void |
| 53 | 53 | { |
| 54 | 54 | $files = new Files(); |
| 55 | - $filename = self::FIXTURE_DIRECTORY . '/test.txt'; |
|
| 55 | + $filename = self::FIXTURE_DIRECTORY.'/test.txt'; |
|
| 56 | 56 | |
| 57 | 57 | $files->write($filename, 'data'); |
| 58 | 58 | $this->assertEquals(md5_file($filename), $files->md5($filename)); |
@@ -65,7 +65,7 @@ discard block |
||
| 65 | 65 | $this->expectException(FileNotFoundException::class); |
| 66 | 66 | |
| 67 | 67 | $files = new Files(); |
| 68 | - $filename = self::FIXTURE_DIRECTORY . '/test.txt'; |
|
| 68 | + $filename = self::FIXTURE_DIRECTORY.'/test.txt'; |
|
| 69 | 69 | |
| 70 | 70 | $files->md5($filename); |
| 71 | 71 | } |
@@ -82,7 +82,7 @@ discard block |
||
| 82 | 82 | public function testExists(): void |
| 83 | 83 | { |
| 84 | 84 | $files = new Files(); |
| 85 | - $filename = self::FIXTURE_DIRECTORY . '/test.txt'; |
|
| 85 | + $filename = self::FIXTURE_DIRECTORY.'/test.txt'; |
|
| 86 | 86 | |
| 87 | 87 | $this->assertFalse($files->exists($filename)); |
| 88 | 88 | $this->assertSame(file_exists($filename), $files->exists($filename)); |
@@ -95,7 +95,7 @@ discard block |
||
| 95 | 95 | public function testSize(): void |
| 96 | 96 | { |
| 97 | 97 | $files = new Files(); |
| 98 | - $filename = self::FIXTURE_DIRECTORY . '/test.txt'; |
|
| 98 | + $filename = self::FIXTURE_DIRECTORY.'/test.txt'; |
|
| 99 | 99 | |
| 100 | 100 | $this->assertFalse($files->exists($filename)); |
| 101 | 101 | $files->write($filename, 'some-data-string'); |
@@ -110,7 +110,7 @@ discard block |
||
| 110 | 110 | $this->expectException(FileNotFoundException::class); |
| 111 | 111 | |
| 112 | 112 | $files = new Files(); |
| 113 | - $filename = self::FIXTURE_DIRECTORY . '/test.txt'; |
|
| 113 | + $filename = self::FIXTURE_DIRECTORY.'/test.txt'; |
|
| 114 | 114 | |
| 115 | 115 | $this->assertFalse($files->exists($filename)); |
| 116 | 116 | $files->size($filename); |
@@ -119,7 +119,7 @@ discard block |
||
| 119 | 119 | public function testLocalUri(): void |
| 120 | 120 | { |
| 121 | 121 | $files = new Files(); |
| 122 | - $filename = self::FIXTURE_DIRECTORY . '/test.txt'; |
|
| 122 | + $filename = self::FIXTURE_DIRECTORY.'/test.txt'; |
|
| 123 | 123 | |
| 124 | 124 | $this->assertFalse($files->exists($filename)); |
| 125 | 125 | $files->write($filename, 'data'); |
@@ -129,7 +129,7 @@ discard block |
||
| 129 | 129 | public function testIsFile(): void |
| 130 | 130 | { |
| 131 | 131 | $files = new Files(); |
| 132 | - $filename = self::FIXTURE_DIRECTORY . '/test.txt'; |
|
| 132 | + $filename = self::FIXTURE_DIRECTORY.'/test.txt'; |
|
| 133 | 133 | |
| 134 | 134 | $this->assertFalse($files->exists($filename)); |
| 135 | 135 | $files->write($filename, 'data'); |
@@ -145,7 +145,7 @@ discard block |
||
| 145 | 145 | public function testIsMissingFile(): void |
| 146 | 146 | { |
| 147 | 147 | $files = new Files(); |
| 148 | - $filename = self::FIXTURE_DIRECTORY . '/test.txt'; |
|
| 148 | + $filename = self::FIXTURE_DIRECTORY.'/test.txt'; |
|
| 149 | 149 | |
| 150 | 150 | $this->assertFalse($files->exists($filename)); |
| 151 | 151 | |
@@ -159,7 +159,7 @@ discard block |
||
| 159 | 159 | public function testIsDirectory(): void |
| 160 | 160 | { |
| 161 | 161 | $files = new Files(); |
| 162 | - $directory = self::FIXTURE_DIRECTORY . '/directory/'; |
|
| 162 | + $directory = self::FIXTURE_DIRECTORY.'/directory/'; |
|
| 163 | 163 | |
| 164 | 164 | $this->assertFalse($files->exists($directory)); |
| 165 | 165 | $files->ensureDirectory($directory); |
@@ -175,7 +175,7 @@ discard block |
||
| 175 | 175 | public function testIsMissingDirectory(): void |
| 176 | 176 | { |
| 177 | 177 | $files = new Files(); |
| 178 | - $directory = self::FIXTURE_DIRECTORY . '/directory/'; |
|
| 178 | + $directory = self::FIXTURE_DIRECTORY.'/directory/'; |
|
| 179 | 179 | |
| 180 | 180 | $this->assertFalse($files->exists($directory)); |
| 181 | 181 | |
@@ -189,7 +189,7 @@ discard block |
||
| 189 | 189 | public function testIsDirectoryNoSlash(): void |
| 190 | 190 | { |
| 191 | 191 | $files = new Files(); |
| 192 | - $directory = self::FIXTURE_DIRECTORY . '/directory'; |
|
| 192 | + $directory = self::FIXTURE_DIRECTORY.'/directory'; |
|
| 193 | 193 | |
| 194 | 194 | $this->assertFalse($files->exists($directory)); |
| 195 | 195 | $files->ensureDirectory($directory); |