| Conditions | 6 |
| Paths | 9 |
| Total Lines | 53 |
| Code Lines | 29 |
| Lines | 0 |
| Ratio | 0 % |
| Changes | 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 |
||
| 45 | public static function getFileStatus($file_path, $original_file_path, $redirectFile) |
||
| 46 | { |
||
| 47 | global $pathIcon16; |
||
| 48 | |||
| 49 | if (empty($file_path)) { |
||
| 50 | return false; |
||
| 51 | } |
||
| 52 | |||
| 53 | if (null === $redirectFile) { |
||
|
|
|||
| 54 | $redirectFile = $_SERVER['SCRIPT_NAME']; |
||
| 55 | } |
||
| 56 | |||
| 57 | $moduleDirName = \basename(\dirname(__DIR__, 2)); |
||
| 58 | |||
| 59 | $moduleDirNameUpper = mb_strtoupper($moduleDirName); |
||
| 60 | |||
| 61 | if (null === $original_file_path) { |
||
| 62 | if (self::fileExists($file_path)) { |
||
| 63 | $path_status = "<img src='$pathIcon16/1.png' >"; |
||
| 64 | |||
| 65 | $path_status .= "$file_path (" . \constant('CO_' . $moduleDirNameUpper . '_' . 'FC_AVAILABLE') . ') '; |
||
| 66 | } else { |
||
| 67 | $path_status = "<img src='$pathIcon16/0.png' >"; |
||
| 68 | |||
| 69 | $path_status .= "$file_path (" . \constant('CO_' . $moduleDirNameUpper . '_' . 'FC_NOTAVAILABLE') . ') '; |
||
| 70 | } |
||
| 71 | } else { |
||
| 72 | if (self::compareFiles($file_path, $original_file_path)) { |
||
| 73 | $path_status = "<img src='$pathIcon16/1.png' >"; |
||
| 74 | |||
| 75 | $path_status .= "$file_path (" . \constant('CO_' . $moduleDirNameUpper . '_' . 'FC_AVAILABLE') . ') '; |
||
| 76 | } else { |
||
| 77 | $path_status = "<img src='$pathIcon16/0.png' >"; |
||
| 78 | |||
| 79 | $path_status .= "$file_path (" . \constant('CO_' . $moduleDirNameUpper . '_' . 'FC_NOTAVAILABLE') . ') '; |
||
| 80 | |||
| 81 | $path_status .= "<form action='" . $_SERVER['SCRIPT_NAME'] . "' method='post'>"; |
||
| 82 | |||
| 83 | $path_status .= "<input type='hidden' name='op' value='copyfile'>"; |
||
| 84 | |||
| 85 | $path_status .= "<input type='hidden' name='file_path' value='$file_path'>"; |
||
| 86 | |||
| 87 | $path_status .= "<input type='hidden' name='original_file_path' value='$original_file_path'>"; |
||
| 88 | |||
| 89 | $path_status .= "<input type='hidden' name='redirect' value='$redirectFile'>"; |
||
| 90 | |||
| 91 | $path_status .= "<button class='submit' onClick='this.form.submit();'>" . \constant('CO_' . $moduleDirNameUpper . '_' . 'FC_CREATETHEFILE') . '</button>'; |
||
| 92 | |||
| 93 | $path_status .= '</form>'; |
||
| 94 | } |
||
| 95 | } |
||
| 96 | |||
| 97 | return $path_status; |
||
| 98 | } |
||
| 182 |