| Conditions | 11 |
| Paths | 8 |
| Total Lines | 28 |
| Code Lines | 17 |
| 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 |
||
| 4 | function sn_sys_load_php_files($dir_name, $load_extension = '.php', $modules = false) { |
||
| 5 | if(!file_exists($dir_name) || !is_dir($dir_name)) { |
||
| 6 | return; |
||
| 7 | } |
||
| 8 | |||
| 9 | $dir = opendir($dir_name); |
||
| 10 | while (($file = readdir($dir)) !== false) { |
||
| 11 | if ($file == '..' || $file == '.') { |
||
| 12 | continue; |
||
| 13 | } |
||
| 14 | |||
| 15 | $full_filename = $dir_name . $file; |
||
| 16 | if ($modules && is_dir($full_filename)) { |
||
| 17 | if (file_exists($full_filename = "{$full_filename}/{$file}{$load_extension}")) { |
||
| 18 | require_once($full_filename); |
||
| 19 | // Registering module |
||
| 20 | if (class_exists($file)) { |
||
| 21 | new $file($full_filename); |
||
| 22 | } |
||
| 23 | } |
||
| 24 | } else { |
||
| 25 | $extension = substr($full_filename, -strlen($load_extension)); |
||
| 26 | if ($extension == $load_extension) { |
||
| 27 | require_once($full_filename); |
||
| 28 | } |
||
| 29 | } |
||
| 30 | } |
||
| 31 | } |
||
| 32 | |||
| 76 |