| Conditions | 6 |
| Paths | 9 |
| Total Lines | 81 |
| Code Lines | 42 |
| 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 |
||
| 46 | public static function getDirectoryStatus($path, $mode = 0777, $redirectFile = null) |
||
| 47 | { |
||
| 48 | global $pathIcon16; |
||
| 49 | |||
| 50 | if (empty($path)) { |
||
| 51 | return false; |
||
| 52 | } |
||
| 53 | |||
| 54 | if (null === $redirectFile) { |
||
| 55 | $redirectFile = $_SERVER['SCRIPT_NAME']; |
||
| 56 | } |
||
| 57 | |||
| 58 | $moduleDirName = \basename(\dirname(__DIR__, 2)); |
||
| 59 | |||
| 60 | $moduleDirNameUpper = mb_strtoupper($moduleDirName); |
||
| 61 | |||
| 62 | if (!@\is_dir($path)) { |
||
| 63 | $path_status = "<img src='$pathIcon16/0.png' >"; |
||
| 64 | |||
| 65 | $path_status .= "$path (" . \constant('CO_' . $moduleDirNameUpper . '_' . 'DC_NOTAVAILABLE') . ') '; |
||
| 66 | |||
| 67 | $path_status .= "<form action='" . $_SERVER['SCRIPT_NAME'] . "' method='post'>"; |
||
| 68 | |||
| 69 | $path_status .= "<input type='hidden' name='op' value='createdir'>"; |
||
| 70 | |||
| 71 | $path_status .= "<input type='hidden' name='path' value='$path'>"; |
||
| 72 | |||
| 73 | $path_status .= "<input type='hidden' name='redirect' value='$redirectFile'>"; |
||
| 74 | |||
| 75 | $path_status .= "<button class='submit' onClick='this.form.submit();'>" . \constant('CO_' . $moduleDirNameUpper . '_' . 'DC_CREATETHEDIR') . '</button>'; |
||
| 76 | |||
| 77 | $path_status .= '</form>'; |
||
| 78 | } elseif (@\is_writable($path)) { |
||
| 79 | $path_status = "<img src='$pathIcon16/1.png' >"; |
||
| 80 | |||
| 81 | $path_status .= "$path (" . \constant('CO_' . $moduleDirNameUpper . '_' . 'DC_AVAILABLE') . ') '; |
||
| 82 | |||
| 83 | $currentMode = mb_substr(\decoct(\fileperms($path)), 2); |
||
| 84 | |||
| 85 | if ($currentMode != \decoct($mode)) { |
||
| 86 | $path_status = "<img src='$pathIcon16/0.png' >"; |
||
| 87 | |||
| 88 | $path_status .= $path . \sprintf(\constant('CO_' . $moduleDirNameUpper . '_' . 'DC_NOTWRITABLE'), \decoct($mode), $currentMode); |
||
| 89 | |||
| 90 | $path_status .= "<form action='" . $_SERVER['SCRIPT_NAME'] . "' method='post'>"; |
||
| 91 | |||
| 92 | $path_status .= "<input type='hidden' name='op' value='setdirperm'>"; |
||
| 93 | |||
| 94 | $path_status .= "<input type='hidden' name='mode' value='$mode'>"; |
||
| 95 | |||
| 96 | $path_status .= "<input type='hidden' name='path' value='$path'>"; |
||
| 97 | |||
| 98 | $path_status .= "<input type='hidden' name='redirect' value='$redirectFile'>"; |
||
| 99 | |||
| 100 | $path_status .= "<button class='submit' onClick='this.form.submit();'>" . \constant('CO_' . $moduleDirNameUpper . '_' . 'DC_SETMPERM') . '</button>'; |
||
| 101 | |||
| 102 | $path_status .= '</form>'; |
||
| 103 | } |
||
| 104 | } else { |
||
| 105 | $currentMode = mb_substr(\decoct(\fileperms($path)), 2); |
||
| 106 | |||
| 107 | $path_status = "<img src='$pathIcon16/0.png' >"; |
||
| 108 | |||
| 109 | $path_status .= $path . \sprintf(\constant('CO_' . $moduleDirNameUpper . '_' . 'DC_NOTWRITABLE'), \decoct($mode), $currentMode); |
||
| 110 | |||
| 111 | $path_status .= "<form action='" . $_SERVER['SCRIPT_NAME'] . "' method='post'>"; |
||
| 112 | |||
| 113 | $path_status .= "<input type='hidden' name='op' value='setdirperm'>"; |
||
| 114 | |||
| 115 | $path_status .= "<input type='hidden' name='mode' value='$mode'>"; |
||
| 116 | |||
| 117 | $path_status .= "<input type='hidden' name='path' value='$path'>"; |
||
| 118 | |||
| 119 | $path_status .= "<input type='hidden' name='redirect' value='$redirectFile'>"; |
||
| 120 | |||
| 121 | $path_status .= "<button class='submit' onClick='this.form.submit();'>" . \constant('CO_' . $moduleDirNameUpper . '_' . 'DC_SETMPERM') . '</button>'; |
||
| 122 | |||
| 123 | $path_status .= '</form>'; |
||
| 124 | } |
||
| 125 | |||
| 126 | return $path_status; |
||
| 127 | } |
||
| 194 |