@@ -17,7 +17,7 @@ discard block |
||
| 17 | 17 | /** |
| 18 | 18 | * @property string $path |
| 19 | 19 | */ |
| 20 | -abstract class FSAbstract implements FSInterface{ |
|
| 20 | +abstract class FSAbstract implements FSInterface { |
|
| 21 | 21 | |
| 22 | 22 | /** |
| 23 | 23 | * @var \chillerlan\Filereader\Drivers\FSDriverInterface |
@@ -34,7 +34,7 @@ discard block |
||
| 34 | 34 | * |
| 35 | 35 | * @param \chillerlan\Filereader\Drivers\FSDriverInterface $driver |
| 36 | 36 | */ |
| 37 | - public function __construct(FSDriverInterface $driver){ |
|
| 37 | + public function __construct(FSDriverInterface $driver) { |
|
| 38 | 38 | $this->filereader = $driver; |
| 39 | 39 | } |
| 40 | 40 | |
@@ -43,9 +43,9 @@ discard block |
||
| 43 | 43 | * |
| 44 | 44 | * @return mixed |
| 45 | 45 | */ |
| 46 | - public function __get(string $name){ |
|
| 46 | + public function __get(string $name) { |
|
| 47 | 47 | |
| 48 | - if(property_exists($this, $name) && $name !== 'filereader'){ |
|
| 48 | + if (property_exists($this, $name) && $name !== 'filereader') { |
|
| 49 | 49 | return $this->{$name}; |
| 50 | 50 | } |
| 51 | 51 | |
@@ -18,7 +18,7 @@ discard block |
||
| 18 | 18 | * @property string $name |
| 19 | 19 | * @property \chillerlan\Filereader\Directory $directory |
| 20 | 20 | */ |
| 21 | -class File extends FSAbstract{ |
|
| 21 | +class File extends FSAbstract { |
|
| 22 | 22 | |
| 23 | 23 | /** |
| 24 | 24 | * @var string |
@@ -37,7 +37,7 @@ discard block |
||
| 37 | 37 | * @param \chillerlan\Filereader\Directory $directory |
| 38 | 38 | * @param string $name |
| 39 | 39 | */ |
| 40 | - public function __construct(FSDriverInterface $driver, Directory $directory, string $name){ |
|
| 40 | + public function __construct(FSDriverInterface $driver, Directory $directory, string $name) { |
|
| 41 | 41 | parent::__construct($driver); |
| 42 | 42 | |
| 43 | 43 | $this->directory = $directory; |
@@ -62,7 +62,7 @@ discard block |
||
| 62 | 62 | /** |
| 63 | 63 | * @return mixed |
| 64 | 64 | */ |
| 65 | - public function getRequire(){ |
|
| 65 | + public function getRequire() { |
|
| 66 | 66 | return $this->filereader->getRequire($this->path); |
| 67 | 67 | } |
| 68 | 68 | |
@@ -85,11 +85,11 @@ discard block |
||
| 85 | 85 | */ |
| 86 | 86 | public function rename(string $newname, bool $overwrite = true):File{ |
| 87 | 87 | |
| 88 | - if(!$this->filereader->rename($this->path, $newname, $overwrite)){ |
|
| 88 | + if (!$this->filereader->rename($this->path, $newname, $overwrite)) { |
|
| 89 | 89 | throw new FilereaderException('cannot rename '.$this->path.' to '.$newname); // @codeCoverageIgnore |
| 90 | 90 | } |
| 91 | 91 | |
| 92 | - if(!$this->filereader->isFile($newname)){ |
|
| 92 | + if (!$this->filereader->isFile($newname)) { |
|
| 93 | 93 | throw new FilereaderException('file not found: '.$newname); // @codeCoverageIgnore |
| 94 | 94 | } |
| 95 | 95 | |
@@ -14,7 +14,7 @@ discard block |
||
| 14 | 14 | |
| 15 | 15 | use chillerlan\Filereader\Drivers\FSDriverInterface; |
| 16 | 16 | |
| 17 | -class Directory extends FSAbstract{ |
|
| 17 | +class Directory extends FSAbstract { |
|
| 18 | 18 | |
| 19 | 19 | /** |
| 20 | 20 | * Directory constructor. |
@@ -22,7 +22,7 @@ discard block |
||
| 22 | 22 | * @param \chillerlan\Filereader\Drivers\FSDriverInterface $driver |
| 23 | 23 | * @param string $path |
| 24 | 24 | */ |
| 25 | - public function __construct(FSDriverInterface $driver, string $path){ |
|
| 25 | + public function __construct(FSDriverInterface $driver, string $path) { |
|
| 26 | 26 | parent::__construct($driver); |
| 27 | 27 | |
| 28 | 28 | $this->path = $path; |
@@ -47,7 +47,7 @@ discard block |
||
| 47 | 47 | */ |
| 48 | 48 | public function read():array{ |
| 49 | 49 | |
| 50 | - if(!$this->filereader->isDir($this->path)){ |
|
| 50 | + if (!$this->filereader->isDir($this->path)) { |
|
| 51 | 51 | throw new FilereaderException('Directory not found: '.$this->path); |
| 52 | 52 | } |
| 53 | 53 | |
@@ -55,11 +55,11 @@ discard block |
||
| 55 | 55 | |
| 56 | 56 | $filelist = []; |
| 57 | 57 | |
| 58 | - if(is_array($dir)){ |
|
| 58 | + if (is_array($dir)) { |
|
| 59 | 59 | |
| 60 | - foreach($dir as $file){ |
|
| 60 | + foreach ($dir as $file) { |
|
| 61 | 61 | |
| 62 | - if(in_array($file, ['.', '..'], true)){ |
|
| 62 | + if (in_array($file, ['.', '..'], true)) { |
|
| 63 | 63 | continue; |
| 64 | 64 | } |
| 65 | 65 | |
@@ -77,7 +77,7 @@ discard block |
||
| 77 | 77 | */ |
| 78 | 78 | public function create(string $subdir = null):bool{ |
| 79 | 79 | |
| 80 | - if($subdir && $this->filereader->isDir($this->path)){ |
|
| 80 | + if ($subdir && $this->filereader->isDir($this->path)) { |
|
| 81 | 81 | return $this->filereader->makeDir($this->path.DIRECTORY_SEPARATOR.$subdir); |
| 82 | 82 | } |
| 83 | 83 | |
@@ -91,7 +91,7 @@ discard block |
||
| 91 | 91 | */ |
| 92 | 92 | public function delete(string $subdir = null):bool{ |
| 93 | 93 | |
| 94 | - if($subdir && $this->filereader->isDir($this->path)){ |
|
| 94 | + if ($subdir && $this->filereader->isDir($this->path)) { |
|
| 95 | 95 | return $this->filereader->deleteDir($this->path.DIRECTORY_SEPARATOR.$subdir); |
| 96 | 96 | } |
| 97 | 97 | |
@@ -107,7 +107,7 @@ discard block |
||
| 107 | 107 | */ |
| 108 | 108 | public function rename(string $newname, bool $overwrite = true):Directory{ |
| 109 | 109 | |
| 110 | - if(!$this->filereader->rename($this->path, $newname, $overwrite)){ |
|
| 110 | + if (!$this->filereader->rename($this->path, $newname, $overwrite)) { |
|
| 111 | 111 | throw new FilereaderException('cannot rename '.$this->path.' to '.$newname); // @codeCoverageIgnore |
| 112 | 112 | } |
| 113 | 113 | |
@@ -18,7 +18,7 @@ discard block |
||
| 18 | 18 | * writeFile |
| 19 | 19 | * |
| 20 | 20 | */ |
| 21 | -interface FSDriverInterface{ |
|
| 21 | +interface FSDriverInterface { |
|
| 22 | 22 | |
| 23 | 23 | /** |
| 24 | 24 | * Checks if the given file exists. |
@@ -132,7 +132,7 @@ discard block |
||
| 132 | 132 | * |
| 133 | 133 | * @return int|null |
| 134 | 134 | */ |
| 135 | - public function fileModifyTime(string $path):?int; |
|
| 135 | + public function fileModifyTime(string $path): ?int; |
|
| 136 | 136 | |
| 137 | 137 | /** |
| 138 | 138 | * @param string $path |
@@ -18,7 +18,7 @@ discard block |
||
| 18 | 18 | /** |
| 19 | 19 | * |
| 20 | 20 | */ |
| 21 | -class DiskDriver implements FSDriverInterface{ |
|
| 21 | +class DiskDriver implements FSDriverInterface { |
|
| 22 | 22 | |
| 23 | 23 | /** |
| 24 | 24 | * Checks if the given file exists. |
@@ -63,7 +63,7 @@ discard block |
||
| 63 | 63 | */ |
| 64 | 64 | public function fileContents(string $path):string{ |
| 65 | 65 | |
| 66 | - if(!$this->isFile($path)){ |
|
| 66 | + if (!$this->isFile($path)) { |
|
| 67 | 67 | throw new FilereaderException('File not found: '.$path); |
| 68 | 68 | } |
| 69 | 69 | |
@@ -79,9 +79,9 @@ discard block |
||
| 79 | 79 | * @return mixed the file's executed contents |
| 80 | 80 | * @throws \chillerlan\Filereader\FilereaderException |
| 81 | 81 | */ |
| 82 | - public function getRequire(string $path){ |
|
| 82 | + public function getRequire(string $path) { |
|
| 83 | 83 | |
| 84 | - if(!$this->isFile($path)){ |
|
| 84 | + if (!$this->isFile($path)) { |
|
| 85 | 85 | throw new FilereaderException('File not found: '.$path); |
| 86 | 86 | } |
| 87 | 87 | |
@@ -98,7 +98,7 @@ discard block |
||
| 98 | 98 | */ |
| 99 | 99 | public function makeDir(string $path):bool{ |
| 100 | 100 | |
| 101 | - if($this->isDir($path)){ |
|
| 101 | + if ($this->isDir($path)) { |
|
| 102 | 102 | throw new FilereaderException('Directory already exists: '.$path); |
| 103 | 103 | } |
| 104 | 104 | |
@@ -115,7 +115,7 @@ discard block |
||
| 115 | 115 | */ |
| 116 | 116 | public function deleteDir(string $path):bool{ |
| 117 | 117 | |
| 118 | - if(!$this->isDir($path)){ |
|
| 118 | + if (!$this->isDir($path)) { |
|
| 119 | 119 | throw new FilereaderException('Directory not found: '.$path); |
| 120 | 120 | } |
| 121 | 121 | |
@@ -132,7 +132,7 @@ discard block |
||
| 132 | 132 | */ |
| 133 | 133 | public function deleteFile(string $path):bool{ |
| 134 | 134 | |
| 135 | - if(!$this->isFile($path)){ |
|
| 135 | + if (!$this->isFile($path)) { |
|
| 136 | 136 | throw new FilereaderException('File not found: '.$path); |
| 137 | 137 | } |
| 138 | 138 | |
@@ -151,7 +151,7 @@ discard block |
||
| 151 | 151 | */ |
| 152 | 152 | public function rename(string $oldname, string $newname, bool $overwrite = true):bool{ |
| 153 | 153 | |
| 154 | - if(!$overwrite && ($this->fileExists($newname) || $this->isDir($newname))){ |
|
| 154 | + if (!$overwrite && ($this->fileExists($newname) || $this->isDir($newname))) { |
|
| 155 | 155 | throw new FilereaderException('Destination already exists.'); |
| 156 | 156 | } |
| 157 | 157 | |
@@ -170,7 +170,7 @@ discard block |
||
| 170 | 170 | */ |
| 171 | 171 | public function copyFile(string $source, string $destination, bool $overwrite = true):bool{ |
| 172 | 172 | |
| 173 | - if(!$overwrite && $this->fileExists($destination)){ |
|
| 173 | + if (!$overwrite && $this->fileExists($destination)) { |
|
| 174 | 174 | throw new FilereaderException('Destination file already exists.'); |
| 175 | 175 | } |
| 176 | 176 | |
@@ -185,9 +185,9 @@ discard block |
||
| 185 | 185 | * @return int|bool |
| 186 | 186 | * @throws \chillerlan\Filereader\FilereaderException |
| 187 | 187 | */ |
| 188 | - public function write(string $path, string $data, bool $overwrite = true){ |
|
| 188 | + public function write(string $path, string $data, bool $overwrite = true) { |
|
| 189 | 189 | |
| 190 | - if(!$overwrite && $this->fileExists($path)){ |
|
| 190 | + if (!$overwrite && $this->fileExists($path)) { |
|
| 191 | 191 | throw new FilereaderException('Destination file already exists.'); |
| 192 | 192 | } |
| 193 | 193 | |
@@ -199,7 +199,7 @@ discard block |
||
| 199 | 199 | * |
| 200 | 200 | * @return int|null |
| 201 | 201 | */ |
| 202 | - public function fileModifyTime(string $path):?int{ |
|
| 202 | + public function fileModifyTime(string $path): ?int{ |
|
| 203 | 203 | return filemtime($path); |
| 204 | 204 | } |
| 205 | 205 | |
@@ -211,7 +211,7 @@ discard block |
||
| 211 | 211 | */ |
| 212 | 212 | public function isWritable(string $path):bool{ |
| 213 | 213 | |
| 214 | - if(!$this->isDir($path)){ |
|
| 214 | + if (!$this->isDir($path)) { |
|
| 215 | 215 | throw new FilereaderException('Directory not found: '.$path); |
| 216 | 216 | } |
| 217 | 217 | |
@@ -12,7 +12,7 @@ |
||
| 12 | 12 | |
| 13 | 13 | namespace chillerlan\Filereader; |
| 14 | 14 | |
| 15 | -interface FSInterface{ |
|
| 15 | +interface FSInterface { |
|
| 16 | 16 | |
| 17 | 17 | /** |
| 18 | 18 | * @param string $name |