@@ -42,11 +42,11 @@ discard block |
||
42 | 42 | /** |
43 | 43 | * Sets the file to store for later |
44 | 44 | * |
45 | - * @param mixed $file |
|
45 | + * @param false|string $file |
|
46 | 46 | * The file to set |
47 | 47 | * @param bool $reset |
48 | 48 | * Whether the counter should be reset when set |
49 | - * @return \mithra62\Files |
|
49 | + * @return Files |
|
50 | 50 | */ |
51 | 51 | public function setFileData($file = false, $reset = false) |
52 | 52 | { |
@@ -91,7 +91,7 @@ discard block |
||
91 | 91 | * |
92 | 92 | * @param string $file |
93 | 93 | * The path to the file to read |
94 | - * @return boolean|string |
|
94 | + * @return false|string |
|
95 | 95 | */ |
96 | 96 | public function read($file) |
97 | 97 | { |
@@ -106,7 +106,7 @@ discard block |
||
106 | 106 | * Removes a file from the file system |
107 | 107 | * |
108 | 108 | * @param string $path |
109 | - * @return bool |
|
109 | + * @return boolean|null |
|
110 | 110 | */ |
111 | 111 | public function delete($path) |
112 | 112 | { |
@@ -122,7 +122,7 @@ discard block |
||
122 | 122 | * |
123 | 123 | * @param string $path |
124 | 124 | * @param string $del_dir |
125 | - * @param number $level |
|
125 | + * @param integer $level |
|
126 | 126 | * @param array $exclude |
127 | 127 | * @return boolean |
128 | 128 | */ |
@@ -164,7 +164,7 @@ discard block |
||
164 | 164 | * |
165 | 165 | * @param string $val |
166 | 166 | * The number to format |
167 | - * @param number $digits |
|
167 | + * @param integer $digits |
|
168 | 168 | * How many digits to display |
169 | 169 | * @param string $mode |
170 | 170 | * Either SI or EIC to determine either 1000 or 1024 bytes |
@@ -74,8 +74,8 @@ discard block |
||
74 | 74 | */ |
75 | 75 | public function write($path, $data, $mode = 'w+') |
76 | 76 | { |
77 | - if (! $fp = fopen($path, $mode)) { |
|
78 | - throw new FileException('Can\'t open the file for writing! ' . $path); |
|
77 | + if (!$fp = fopen($path, $mode)) { |
|
78 | + throw new FileException('Can\'t open the file for writing! '.$path); |
|
79 | 79 | } |
80 | 80 | |
81 | 81 | flock($fp, LOCK_EX); |
@@ -95,7 +95,7 @@ discard block |
||
95 | 95 | */ |
96 | 96 | public function read($file) |
97 | 97 | { |
98 | - if (! file_exists($file)) { |
|
98 | + if (!file_exists($file)) { |
|
99 | 99 | return FALSE; |
100 | 100 | } |
101 | 101 | |
@@ -131,7 +131,7 @@ discard block |
||
131 | 131 | // Trim the trailing slash |
132 | 132 | $path = rtrim($path, DIRECTORY_SEPARATOR); |
133 | 133 | |
134 | - if (! $current_dir = opendir($path)) { |
|
134 | + if (!$current_dir = opendir($path)) { |
|
135 | 135 | return false; |
136 | 136 | } |
137 | 137 | |
@@ -139,11 +139,11 @@ discard block |
||
139 | 139 | $exclude[] = '..'; |
140 | 140 | |
141 | 141 | while (false !== ($filename = readdir($current_dir))) { |
142 | - if (! in_array($filename, $exclude)) { |
|
143 | - if (is_dir($path . DIRECTORY_SEPARATOR . $filename)) { |
|
144 | - $this->deleteDir($path . DIRECTORY_SEPARATOR . $filename, $del_dir); |
|
142 | + if (!in_array($filename, $exclude)) { |
|
143 | + if (is_dir($path.DIRECTORY_SEPARATOR.$filename)) { |
|
144 | + $this->deleteDir($path.DIRECTORY_SEPARATOR.$filename, $del_dir); |
|
145 | 145 | } else { |
146 | - $this->delete($path . DIRECTORY_SEPARATOR . $filename); |
|
146 | + $this->delete($path.DIRECTORY_SEPARATOR.$filename); |
|
147 | 147 | } |
148 | 148 | } |
149 | 149 | } |
@@ -216,7 +216,7 @@ discard block |
||
216 | 216 | $bB = "B"; |
217 | 217 | break; |
218 | 218 | } |
219 | - for ($i = 0; $i < count($symbols) - 1 && $val >= $factor; $i ++) { |
|
219 | + for ($i = 0; $i < count($symbols) - 1 && $val >= $factor; $i++) { |
|
220 | 220 | $val /= $factor; |
221 | 221 | } |
222 | 222 | $p = strpos($val, "."); |
@@ -226,7 +226,7 @@ discard block |
||
226 | 226 | $val = round($val, $digits - $p); |
227 | 227 | } |
228 | 228 | |
229 | - return round($val, $digits) . " " . $symbols[$i] . $bB; |
|
229 | + return round($val, $digits)." ".$symbols[$i].$bB; |
|
230 | 230 | } |
231 | 231 | |
232 | 232 | /** |
@@ -245,9 +245,9 @@ discard block |
||
245 | 245 | $file_extension = strtolower(substr(strrchr($filename, "."), 1)); |
246 | 246 | |
247 | 247 | if ($filename == "") { |
248 | - throw new FileException('Download file NOT SPECIFIED! ' . $filename); |
|
249 | - } elseif (! file_exists($filename)) { |
|
250 | - throw new FileException('Download file NOT Found! ' . $filename); |
|
248 | + throw new FileException('Download file NOT SPECIFIED! '.$filename); |
|
249 | + } elseif (!file_exists($filename)) { |
|
250 | + throw new FileException('Download file NOT Found! '.$filename); |
|
251 | 251 | } |
252 | 252 | ; |
253 | 253 | switch ($file_extension) { |
@@ -292,12 +292,12 @@ discard block |
||
292 | 292 | header("Cache-Control: must-revalidate, post-check=0, pre-check=0"); |
293 | 293 | header("Cache-Control: private", false); |
294 | 294 | header("Content-Type: $ctype"); |
295 | - header("Content-Disposition: attachment; filename=\"" . ($force_name ? $force_name : basename($filename)) . "\";"); |
|
295 | + header("Content-Disposition: attachment; filename=\"".($force_name ? $force_name : basename($filename))."\";"); |
|
296 | 296 | header("Content-Transfer-Encoding: binary"); |
297 | - header("Content-Length: " . $filesize); |
|
297 | + header("Content-Length: ".$filesize); |
|
298 | 298 | |
299 | 299 | if ($fd = fopen($filename, "r")) { |
300 | - while (! feof($fd)) { |
|
300 | + while (!feof($fd)) { |
|
301 | 301 | $buffer = fread($fd, 1024 * 8); |
302 | 302 | echo $buffer; |
303 | 303 | } |
@@ -323,14 +323,14 @@ discard block |
||
323 | 323 | // reset the array and make sure $source_dir has a trailing slash on the initial call |
324 | 324 | if ($recursion === false) { |
325 | 325 | $this->setFileData(false, true); |
326 | - $source_dir = rtrim(realpath($source_dir), DIRECTORY_SEPARATOR) . DIRECTORY_SEPARATOR; |
|
326 | + $source_dir = rtrim(realpath($source_dir), DIRECTORY_SEPARATOR).DIRECTORY_SEPARATOR; |
|
327 | 327 | } |
328 | 328 | |
329 | 329 | while (false !== ($file = readdir($fp))) { |
330 | - if (is_dir($source_dir . $file) && strncmp($file, '.', 1) !== 0) { |
|
331 | - $this->getFilenames($source_dir . $file . DIRECTORY_SEPARATOR, $include_path, TRUE); |
|
330 | + if (is_dir($source_dir.$file) && strncmp($file, '.', 1) !== 0) { |
|
331 | + $this->getFilenames($source_dir.$file.DIRECTORY_SEPARATOR, $include_path, TRUE); |
|
332 | 332 | } elseif (strncmp($file, '.', 1) !== 0) { |
333 | - $filedata = ($include_path === TRUE) ? $source_dir . DIRECTORY_SEPARATOR . $file : $file; |
|
333 | + $filedata = ($include_path === TRUE) ? $source_dir.DIRECTORY_SEPARATOR.$file : $file; |
|
334 | 334 | $this->setFileData($filedata); |
335 | 335 | } |
336 | 336 | } |
@@ -353,10 +353,10 @@ discard block |
||
353 | 353 | { |
354 | 354 | foreach ($iterator = new \RecursiveIteratorIterator(new \RecursiveDirectoryIterator(trim($dir), \RecursiveDirectoryIterator::SKIP_DOTS), \RecursiveIteratorIterator::SELF_FIRST) as $item) { |
355 | 355 | |
356 | - if ($item->isDir() && !file_exists($destination . DIRECTORY_SEPARATOR . $iterator->getSubPathName())) { |
|
357 | - mkdir($destination . DIRECTORY_SEPARATOR . $iterator->getSubPathName(), '0777', true); |
|
356 | + if ($item->isDir() && !file_exists($destination.DIRECTORY_SEPARATOR.$iterator->getSubPathName())) { |
|
357 | + mkdir($destination.DIRECTORY_SEPARATOR.$iterator->getSubPathName(), '0777', true); |
|
358 | 358 | } else { |
359 | - copy($item, $destination . DIRECTORY_SEPARATOR . $iterator->getSubPathName()); |
|
359 | + copy($item, $destination.DIRECTORY_SEPARATOR.$iterator->getSubPathName()); |
|
360 | 360 | } |
361 | 361 | } |
362 | 362 | } |