| Conditions | 16 |
| Paths | 19 |
| Total Lines | 40 |
| Code Lines | 19 |
| Lines | 0 |
| Ratio | 0 % |
| Changes | 1 | ||
| Bugs | 0 | Features | 0 |
Small methods make your code easier to understand, in particular if combined with a good name. Besides, if your method is small, finding a good name is usually much easier.
For example, if you find yourself adding comments to a method's body, this is usually a good sign to extract the commented part to a new method, and use the comment as a starting point when coming up with a good name for this new method.
Commonly applied refactorings include:
If many parameters/temporary variables are present:
| 1 | <?php |
||
| 71 | function purgeTemporaryFiles(): void |
||
| 72 | { |
||
| 73 | // Load expected files |
||
| 74 | require_once __DIR__. '/../sources/main.functions.php'; |
||
| 75 | include __DIR__. '/../includes/config/tp.config.php'; |
||
| 76 | |||
| 77 | if (isset($SETTINGS) === true) { |
||
|
1 ignored issue
–
show
|
|||
| 78 | //read folder |
||
| 79 | if (is_dir($SETTINGS['path_to_files_folder']) === true) { |
||
| 80 | $dir = opendir($SETTINGS['path_to_files_folder']); |
||
| 81 | if ($dir !== false) { |
||
| 82 | //delete file FILES |
||
| 83 | while (false !== ($f = readdir($dir))) { |
||
| 84 | if ($f !== '.' && $f !== '..' && $f !== '.htaccess') { |
||
| 85 | if (file_exists($dir . $f) && ((time() - filectime($dir . $f)) > 604800)) { |
||
| 86 | fileDelete($dir . '/' . $f, $SETTINGS); |
||
| 87 | } |
||
| 88 | } |
||
| 89 | } |
||
| 90 | |||
| 91 | //Close dir |
||
| 92 | closedir($dir); |
||
| 93 | } |
||
| 94 | } |
||
| 95 | |||
| 96 | //read folder UPLOAD |
||
| 97 | if (is_dir($SETTINGS['path_to_upload_folder']) === true) { |
||
| 98 | $dir = opendir($SETTINGS['path_to_upload_folder']); |
||
| 99 | |||
| 100 | if ($dir !== false) { |
||
| 101 | //delete file |
||
| 102 | while (false !== ($f = readdir($dir))) { |
||
| 103 | if ($f !== '.' && $f !== '..') { |
||
| 104 | if (strpos($f, '_delete.') > 0) { |
||
| 105 | fileDelete($SETTINGS['path_to_upload_folder'] . '/' . $f, $SETTINGS); |
||
| 106 | } |
||
| 107 | } |
||
| 108 | } |
||
| 109 | //Close dir |
||
| 110 | closedir($dir); |
||
| 111 | } |
||
| 115 | } |