| Conditions | 10 |
| Paths | 8 |
| Total Lines | 31 |
| Code Lines | 24 |
| 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 |
||
| 32 | public static function go($argv) { |
||
| 33 | $argv = self::clean_argv($argv); |
||
| 34 | if(empty($argv) || (!empty($argv) && $argv[0] === '-h') || (!empty($argv) && $argv[0] === '--help')) { |
||
| 35 | $argv = self::clean_argv($argv); |
||
| 36 | if(is_file("phoponent/commands/help.php")) { |
||
| 37 | require_once "phoponent/commands/help.php"; |
||
| 38 | } |
||
| 39 | else { |
||
| 40 | throw new Exception("command help not found !"); |
||
| 41 | } |
||
| 42 | $command = new help($argv); |
||
| 43 | $command->execute(); |
||
| 44 | return; |
||
| 45 | } |
||
| 46 | $command = explode(':', $argv[0]); |
||
| 47 | $command_class = $command[0]; |
||
| 48 | $command_method = isset($command[1]) ? $command[1] : null; |
||
| 49 | $argv = self::clean_argv($argv); |
||
| 50 | if(is_file("phoponent/commands/{$command_class}.php")) { |
||
| 51 | require_once "phoponent/commands/{$command_class}.php"; |
||
| 52 | } |
||
| 53 | else { |
||
| 54 | throw new Exception("command {$command_class} not found !"); |
||
| 55 | } |
||
| 56 | $command_class = "\\phoponent\\framework\\command\\{$command_class}"; |
||
| 57 | $command_obj = new $command_class($argv); |
||
| 58 | if($command_method) { |
||
| 59 | $command_obj->execute($command_method); |
||
| 60 | } |
||
| 61 | else { |
||
| 62 | $command_obj->execute(); |
||
| 63 | } |
||
| 65 | } |