@@ -15,6 +15,6 @@ |
||
15 | 15 | /** |
16 | 16 | * |
17 | 17 | */ |
18 | -class FilereaderException extends \Exception{ |
|
18 | +class FilereaderException extends \Exception { |
|
19 | 19 | |
20 | 20 | } |
@@ -18,7 +18,7 @@ |
||
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. |
@@ -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 |
@@ -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 | $this->filereader = $driver; |
42 | 42 | $this->directory = $directory; |
43 | 43 | $this->name = $name; |
@@ -61,7 +61,7 @@ discard block |
||
61 | 61 | /** |
62 | 62 | * @return mixed |
63 | 63 | */ |
64 | - public function getRequire(){ |
|
64 | + public function getRequire() { |
|
65 | 65 | return $this->filereader->getRequire($this->path); |
66 | 66 | } |
67 | 67 | |
@@ -84,7 +84,7 @@ discard block |
||
84 | 84 | */ |
85 | 85 | public function rename(string $newname, bool $overwrite = true):File{ |
86 | 86 | |
87 | - if(!$this->filereader->rename($this->path, $newname, $overwrite)){ |
|
87 | + if (!$this->filereader->rename($this->path, $newname, $overwrite)) { |
|
88 | 88 | throw new FilereaderException('cannot rename '.$this->path.' to '.$newname); // @codeCoverageIgnore |
89 | 89 | } |
90 | 90 |
@@ -15,7 +15,7 @@ discard block |
||
15 | 15 | /** |
16 | 16 | * @property string $path |
17 | 17 | */ |
18 | -abstract class FSAbstract{ |
|
18 | +abstract class FSAbstract { |
|
19 | 19 | |
20 | 20 | /** |
21 | 21 | * @var \chillerlan\Filereader\Drivers\FSDriverInterface |
@@ -32,9 +32,9 @@ discard block |
||
32 | 32 | * |
33 | 33 | * @return mixed |
34 | 34 | */ |
35 | - public function __get(string $name){ |
|
35 | + public function __get(string $name) { |
|
36 | 36 | |
37 | - if(property_exists($this, $name) && $name !== 'filereader'){ |
|
37 | + if (property_exists($this, $name) && $name !== 'filereader') { |
|
38 | 38 | return $this->{$name}; |
39 | 39 | } |
40 | 40 |
@@ -17,7 +17,7 @@ discard block |
||
17 | 17 | /** |
18 | 18 | * |
19 | 19 | */ |
20 | -class Directory extends FSAbstract{ |
|
20 | +class Directory extends FSAbstract { |
|
21 | 21 | |
22 | 22 | /** |
23 | 23 | * Directory constructor. |
@@ -25,7 +25,7 @@ discard block |
||
25 | 25 | * @param \chillerlan\Filereader\Drivers\FSDriverInterface $driver |
26 | 26 | * @param string $path |
27 | 27 | */ |
28 | - public function __construct(FSDriverInterface $driver, string $path){ |
|
28 | + public function __construct(FSDriverInterface $driver, string $path) { |
|
29 | 29 | $this->filereader = $driver; |
30 | 30 | $this->path = $path; |
31 | 31 | } |
@@ -49,7 +49,7 @@ discard block |
||
49 | 49 | */ |
50 | 50 | public function read():array{ |
51 | 51 | |
52 | - if(!$this->filereader->isDir($this->path)){ |
|
52 | + if (!$this->filereader->isDir($this->path)) { |
|
53 | 53 | throw new FilereaderException('Directory not found: '.$this->path); |
54 | 54 | } |
55 | 55 | |
@@ -57,11 +57,11 @@ discard block |
||
57 | 57 | |
58 | 58 | $filelist = []; |
59 | 59 | |
60 | - if(is_array($dir)){ |
|
60 | + if (is_array($dir)) { |
|
61 | 61 | |
62 | - foreach($dir as $file){ |
|
62 | + foreach ($dir as $file) { |
|
63 | 63 | |
64 | - if(in_array($file, ['.', '..'], true)){ |
|
64 | + if (in_array($file, ['.', '..'], true)) { |
|
65 | 65 | continue; |
66 | 66 | } |
67 | 67 | |
@@ -79,7 +79,7 @@ discard block |
||
79 | 79 | */ |
80 | 80 | public function create(string $subdir = null):bool{ |
81 | 81 | |
82 | - if($subdir && $this->filereader->isDir($this->path)){ |
|
82 | + if ($subdir && $this->filereader->isDir($this->path)) { |
|
83 | 83 | return $this->filereader->makeDir($this->path.DIRECTORY_SEPARATOR.$subdir); |
84 | 84 | } |
85 | 85 | |
@@ -93,7 +93,7 @@ discard block |
||
93 | 93 | */ |
94 | 94 | public function delete(string $subdir = null):bool{ |
95 | 95 | |
96 | - if($subdir && $this->filereader->isDir($this->path)){ |
|
96 | + if ($subdir && $this->filereader->isDir($this->path)) { |
|
97 | 97 | return $this->filereader->deleteDir($this->path.DIRECTORY_SEPARATOR.$subdir); |
98 | 98 | } |
99 | 99 | |
@@ -109,7 +109,7 @@ discard block |
||
109 | 109 | */ |
110 | 110 | public function rename(string $newname, bool $overwrite = true):Directory{ |
111 | 111 | |
112 | - if(!$this->filereader->rename($this->path, $newname, $overwrite)){ |
|
112 | + if (!$this->filereader->rename($this->path, $newname, $overwrite)) { |
|
113 | 113 | throw new FilereaderException('cannot rename '.$this->path.' to '.$newname); // @codeCoverageIgnore |
114 | 114 | } |
115 | 115 |