| Conditions | 1 |
| Paths | 1 |
| Total Lines | 254 |
| Code Lines | 245 |
| 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 |
||
| 44 | function function_qualifier($src_path, $dst_path) { |
||
| 45 | |||
| 46 | $patterns = [ |
||
| 47 | //remove backslash if alreadyin order to avoid \\ |
||
| 48 | '\array_diff(' => 'array_diff(', |
||
| 49 | '\array_filter(' => 'array_filter(', |
||
| 50 | '\array_key_exists(' => 'array_key_exists(', |
||
| 51 | '\array_keys(' => 'array_keys(', |
||
| 52 | '\array_search(' => 'array_search(', |
||
| 53 | '\array_slice(' => 'array_slice(', |
||
| 54 | '\array_unshift(' => 'array_unshift(', |
||
| 55 | '\array_values(' => 'array_values(', |
||
| 56 | '\assert(' => 'assert(', |
||
| 57 | '\basename(' => 'basename(', |
||
| 58 | '\boolval(' => 'boolval(', |
||
| 59 | '\call_user_func(' => 'call_user_func(', |
||
| 60 | '\call_user_func_array(' => 'call_user_func_array(', |
||
| 61 | '\chr(' => 'chr(', |
||
| 62 | '\class_exists(' => 'class_exists(', |
||
| 63 | '\closedir(' => 'closedir(', |
||
| 64 | '\constant(' => 'constant(', |
||
| 65 | '\copy(' => 'copy(', |
||
| 66 | '\count(' => 'count(', |
||
| 67 | '\curl_close(' => 'curl_close(', |
||
| 68 | '\curl_error(' => 'curl_error(', |
||
| 69 | '\curl_exec(' => 'curl_exec(', |
||
| 70 | '\curl_file_create(' => 'curl_file_create(', |
||
| 71 | '\curl_getinfo(' => 'curl_getinfo(', |
||
| 72 | '\curl_init(' => 'curl_init(', |
||
| 73 | '\curl_setopt(' => 'curl_setopt(', |
||
| 74 | '\define(' => 'define(', |
||
| 75 | '\defined(' => 'defined(', |
||
| 76 | '\dirname(' => 'dirname(', |
||
| 77 | '\doubleval(' => 'doubleval(', |
||
| 78 | '\explode(' => 'explode(', |
||
| 79 | '\extension_loaded(' => 'extension_loaded(', |
||
| 80 | '\file_exists(' => 'file_exists(', |
||
| 81 | '\finfo_open(' => 'finfo_open(', |
||
| 82 | '\floatval(' => 'floatval(', |
||
| 83 | '\floor(' => 'floor(', |
||
| 84 | '\formatTimestamp(' => 'formatTimestamp(', |
||
| 85 | '\func_get_args(' => 'func_get_args(', |
||
| 86 | '\func_num_args(' => 'func_num_args(', |
||
| 87 | '\function_exists(' => 'function_exists(', |
||
| 88 | '\get_called_class(' => 'get_called_class(', |
||
| 89 | '\get_class(' => 'get_class(', |
||
| 90 | '\getimagesize(' => 'getimagesize(', |
||
| 91 | '\gettype(' => 'gettype(', |
||
| 92 | '\imagecopyresampled(' => 'imagecopyresampled(', |
||
| 93 | '\imagecreatefromgif(' => 'imagecreatefromgif(', |
||
| 94 | '\imagecreatefromjpeg(' => 'imagecreatefromjpeg(', |
||
| 95 | '\imagecreatefrompng(' => 'imagecreatefrompng(', |
||
| 96 | '\imagecreatefromstring(' => 'imagecreatefromstring(', |
||
| 97 | '\imagecreatetruecolor(' => 'imagecreatetruecolor(', |
||
| 98 | '\imagedestroy(' => 'imagedestroy(', |
||
| 99 | '\imagegif(' => 'imagegif(', |
||
| 100 | '\imagejpeg(' => 'imagejpeg(', |
||
| 101 | '\imagepng(' => 'imagepng(', |
||
| 102 | '\imagerotate(' => 'imagerotate(', |
||
| 103 | '\imagesx(' => 'imagesx(', |
||
| 104 | '\imagesy(' => 'imagesy(', |
||
| 105 | '\implode(' => 'implode(', |
||
| 106 | '\in_array(' => 'in_array(', |
||
| 107 | '\ini_get(' => 'ini_get(', |
||
| 108 | '\intval(' => 'intval(', |
||
| 109 | '\is_array(' => 'is_array(', |
||
| 110 | '\is_bool(' => 'is_bool(', |
||
| 111 | '\is_callable(' => 'is_callable(', |
||
| 112 | '\is_dir(' => 'is_dir(', |
||
| 113 | '\is_double(' => 'is_double(', |
||
| 114 | '\is_float(' => 'is_float(', |
||
| 115 | '\is_int(' => 'is_int(', |
||
| 116 | '\is_integer(' => 'is_integer(', |
||
| 117 | '\is_link(' => 'is_link(', |
||
| 118 | '\is_long(' => 'is_long(', |
||
| 119 | '\is_null(' => 'is_null(', |
||
| 120 | '\is_object(' => 'is_object(', |
||
| 121 | '\is_real(' => 'is_real(', |
||
| 122 | '\is_resource(' => 'is_resource(', |
||
| 123 | '\is_string(' => 'is_string(', |
||
| 124 | '\json_decode(' => 'json_decode(', |
||
| 125 | '\json_encode(' => 'json_encode(', |
||
| 126 | '\mime_content_type(' => 'mime_content_type(', |
||
| 127 | '\mkdir(' => 'mkdir(', |
||
| 128 | '\opendir(' => 'opendir(', |
||
| 129 | '\ord(' => 'ord(', |
||
| 130 | '\pathinfo(' => 'pathinfo(', |
||
| 131 | '\preg_match(' => 'preg_match(', |
||
| 132 | '\preg_match_all(' => 'preg_match_all(', |
||
| 133 | '\preg_replace(' => 'preg_replace(', |
||
| 134 | '\readdir(' => 'readdir(', |
||
| 135 | '\readlink(' => 'readlink(', |
||
| 136 | '\redirect_header(' => 'redirect_header(', |
||
| 137 | '\rename(' => 'rename(', |
||
| 138 | '\rmdir(' => 'rmdir(', |
||
| 139 | '\round(' => 'round(', |
||
| 140 | '\scandir(' => 'scandir(', |
||
| 141 | '\sprintf(' => 'sprintf(', |
||
| 142 | '\str_replace(' => 'str_replace(', |
||
| 143 | '\strip_tags(' => 'strip_tags(', |
||
| 144 | '\strlen(' => 'strlen(', |
||
| 145 | '\strpos(' => 'strpos(', |
||
| 146 | '\strtotime(' => 'strtotime(', |
||
| 147 | '\strval(' => 'strval(', |
||
| 148 | '\substr(' => 'substr(', |
||
| 149 | '\symlink(' => 'symlink(', |
||
| 150 | '\time()' => 'time()', |
||
| 151 | '\trigger_error(' => 'trigger_error(', |
||
| 152 | '\trim(' => 'trim(', |
||
| 153 | '\ucfirst(' => 'ucfirst(', |
||
| 154 | '\unlink(' => 'unlink(', |
||
| 155 | '\version_compare(' => 'version_compare(', |
||
| 156 | '\xoops_getHandler(' => 'xoops_getHandler(', |
||
| 157 | '\xoops_load(' => 'xoops_load(', |
||
| 158 | '\xoops_loadLanguage(' => 'xoops_loadLanguage(', |
||
| 159 | '\mb_strtoupper(' => 'mb_strtoupper(', |
||
| 160 | '\mb_strtolower(' => 'mb_strtolower(', |
||
| 161 | '\mb_strpos(' => 'mb_strpos(', |
||
| 162 | '\mb_strlen(' => 'mb_strlen(', |
||
| 163 | '\mb_strrpos(' => 'mb_strrpos(', |
||
| 164 | |||
| 165 | //add backslash to all functions |
||
| 166 | 'array_diff(' => '\array_diff(', |
||
| 167 | 'array_filter(' => '\array_filter(', |
||
| 168 | 'array_key_exists(' => '\array_key_exists(', |
||
| 169 | 'array_keys(' => '\array_keys(', |
||
| 170 | 'array_search(' => '\array_search(', |
||
| 171 | 'array_slice(' => '\array_slice(', |
||
| 172 | 'array_unshift(' => '\array_unshift(', |
||
| 173 | 'array_values(' => '\array_values(', |
||
| 174 | 'assert(' => '\assert(', |
||
| 175 | 'basename(' => '\basename(', |
||
| 176 | 'boolval(' => '\boolval(', |
||
| 177 | 'call_user_func(' => '\call_user_func(', |
||
| 178 | 'call_user_func_array(' => '\call_user_func_array(', |
||
| 179 | 'chr(' => '\chr(', |
||
| 180 | 'class_exists(' => '\class_exists(', |
||
| 181 | 'closedir(' => '\closedir(', |
||
| 182 | 'constant(' => '\constant(', |
||
| 183 | 'copy(' => '\copy(', |
||
| 184 | 'count(' => '\count(', |
||
| 185 | 'curl_close(' => '\curl_close(', |
||
| 186 | 'curl_error(' => '\curl_error(', |
||
| 187 | 'curl_exec(' => '\curl_exec(', |
||
| 188 | 'curl_file_create(' => '\curl_file_create(', |
||
| 189 | 'curl_getinfo(' => '\curl_getinfo(', |
||
| 190 | 'curl_init(' => '\curl_init(', |
||
| 191 | 'curl_setopt(' => '\curl_setopt(', |
||
| 192 | 'define(' => '\define(', |
||
| 193 | 'defined(' => '\defined(', |
||
| 194 | 'dirname(' => '\dirname(', |
||
| 195 | 'doubleval(' => '\doubleval(', |
||
| 196 | 'explode(' => '\explode(', |
||
| 197 | 'extension_loaded(' => '\extension_loaded(', |
||
| 198 | 'file_exists(' => '\file_exists(', |
||
| 199 | 'finfo_open(' => '\finfo_open(', |
||
| 200 | 'floatval(' => '\floatval(', |
||
| 201 | 'floor(' => '\floor(', |
||
| 202 | 'formatTimestamp(' => '\formatTimestamp(', |
||
| 203 | 'func_get_args(' => '\func_get_args(', |
||
| 204 | 'func_num_args(' => '\func_num_args(', |
||
| 205 | 'function_exists(' => '\function_exists(', |
||
| 206 | 'get_called_class(' => '\get_called_class(', |
||
| 207 | 'get_class(' => '\get_class(', |
||
| 208 | 'getimagesize(' => '\getimagesize(', |
||
| 209 | 'gettype(' => '\gettype(', |
||
| 210 | 'imagecopyresampled(' => '\imagecopyresampled(', |
||
| 211 | 'imagecreatefromgif(' => '\imagecreatefromgif(', |
||
| 212 | 'imagecreatefromjpeg(' => '\imagecreatefromjpeg(', |
||
| 213 | 'imagecreatefrompng(' => '\imagecreatefrompng(', |
||
| 214 | 'imagecreatefromstring(' => '\imagecreatefromstring(', |
||
| 215 | 'imagecreatetruecolor(' => '\imagecreatetruecolor(', |
||
| 216 | 'imagedestroy(' => '\imagedestroy(', |
||
| 217 | 'imagegif(' => '\imagegif(', |
||
| 218 | 'imagejpeg(' => '\imagejpeg(', |
||
| 219 | 'imagepng(' => '\imagepng(', |
||
| 220 | 'imagerotate(' => '\imagerotate(', |
||
| 221 | 'imagesx(' => '\imagesx(', |
||
| 222 | 'imagesy(' => '\imagesy(', |
||
| 223 | 'implode(' => '\implode(', |
||
| 224 | 'in_array(' => '\in_array(', |
||
| 225 | 'ini_get(' => '\ini_get(', |
||
| 226 | 'intval(' => '\intval(', |
||
| 227 | 'is_array(' => '\is_array(', |
||
| 228 | 'is_bool(' => '\is_bool(', |
||
| 229 | 'is_callable(' => '\is_callable(', |
||
| 230 | 'is_dir(' => '\is_dir(', |
||
| 231 | 'is_double(' => '\is_double(', |
||
| 232 | 'is_float(' => '\is_float(', |
||
| 233 | 'is_int(' => '\is_int(', |
||
| 234 | 'is_integer(' => '\is_integer(', |
||
| 235 | 'is_link(' => '\is_link(', |
||
| 236 | 'is_long(' => '\is_long(', |
||
| 237 | 'is_null(' => '\is_null(', |
||
| 238 | 'is_object(' => '\is_object(', |
||
| 239 | 'is_real(' => '\is_real(', |
||
| 240 | 'is_resource(' => '\is_resource(', |
||
| 241 | 'is_string(' => '\is_string(', |
||
| 242 | 'json_decode(' => '\json_decode(', |
||
| 243 | 'json_encode(' => '\json_encode(', |
||
| 244 | 'mb_strtoupper(' => '\mb_strtoupper(', |
||
| 245 | 'mb_strtolower(' => '\mb_strtolower(', |
||
| 246 | 'mb_strpos(' => '\mb_strpos(', |
||
| 247 | 'mb_strlen(' => '\mb_strlen(', |
||
| 248 | 'mb_strrpos(' => '\mb_strrpos(', |
||
| 249 | 'mime_content_type(' => '\mime_content_type(', |
||
| 250 | 'mkdir(' => '\mkdir(', |
||
| 251 | 'opendir(' => '\opendir(', |
||
| 252 | 'ord(' => '\ord(', |
||
| 253 | 'pathinfo(' => '\pathinfo(', |
||
| 254 | 'preg_match(' => '\preg_match(', |
||
| 255 | 'preg_match_all(' => '\preg_match_all(', |
||
| 256 | 'preg_replace(' => '\preg_replace(', |
||
| 257 | 'readdir(' => '\readdir(', |
||
| 258 | 'readlink(' => '\readlink(', |
||
| 259 | 'redirect_header(' => '\redirect_header(', |
||
| 260 | 'rename(' => '\rename(', |
||
| 261 | 'rmdir(' => '\rmdir(', |
||
| 262 | 'round(' => '\round(', |
||
| 263 | 'scandir(' => '\scandir(', |
||
| 264 | 'sprintf(' => '\sprintf(', |
||
| 265 | 'str_replace(' => '\str_replace(', |
||
| 266 | 'strip_tags(' => '\strip_tags(', |
||
| 267 | 'strlen(' => '\strlen(', |
||
| 268 | 'strpos(' => '\strpos(', |
||
| 269 | 'strtotime(' => '\strtotime(', |
||
| 270 | 'strval(' => '\strval(', |
||
| 271 | 'substr(' => '\substr(', |
||
| 272 | 'symlink(' => '\symlink(', |
||
| 273 | 'time()' => '\time()', |
||
| 274 | 'trigger_error(' => '\trigger_error(', |
||
| 275 | 'trim(' => '\trim(', |
||
| 276 | 'ucfirst(' => '\ucfirst(', |
||
| 277 | 'unlink(' => '\unlink(', |
||
| 278 | 'version_compare(' => '\version_compare(', |
||
| 279 | 'xoops_getHandler(' => '\xoops_getHandler(', |
||
| 280 | 'xoops_load(' => '\xoops_load(', |
||
| 281 | 'xoops_loadLanguage(' => '\xoops_loadLanguage(', |
||
| 282 | |||
| 283 | //correct errors |
||
| 284 | 'mb_\strlen(' => 'mb_strlen(', |
||
| 285 | 'mb_\substr(' => 'mb_substr(', |
||
| 286 | 'x\copy' => 'xcopy', |
||
| 287 | 'r\rmdir' => 'rrmdir', |
||
| 288 | 'r\copy' => 'rcopy', |
||
| 289 | '\dirname()' => 'dirname()', |
||
| 290 | 'assw\ord' => 'assword', |
||
| 291 | 'mb_\strpos' => 'mb_strpos', |
||
| 292 | 'imagecopy(' => 'imagecopy(', |
||
| 293 | ]; |
||
| 294 | |||
| 295 | $patKeys = \array_keys($patterns); |
||
| 296 | $patValues = \array_values($patterns); |
||
| 297 | cloneFileFolder($src_path, $dst_path, $patKeys, $patValues); |
||
| 298 | |||
| 360 |
If you suppress an error, we recommend checking for the error condition explicitly: