| Conditions | 11 |
| Paths | 11 |
| Total Lines | 30 |
| Code Lines | 22 |
| 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 |
||
| 27 | public function call(array &$args) |
||
| 28 | { |
||
| 29 | if (conf('hook.enable', true) == false) { |
||
| 30 | debug()->warning(__('hook.enable == false refuse run command')); |
||
|
|
|||
| 31 | return null; |
||
| 32 | } |
||
| 33 | if (is_string($command)) { |
||
| 34 | if (preg_match('/^(debug)|d\=/', $command)) { |
||
| 35 | if (conf('debug')) { |
||
| 36 | return (new Command(preg_replace('/^.+?\=/', '', $command)))->exec($args); |
||
| 37 | } |
||
| 38 | } elseif (preg_match('/^(normal)|n\=/', $command)) { |
||
| 39 | if (conf('debug') == false) { |
||
| 40 | return (new Command(preg_replace('/^.+?\=/', '', $command)))->exec($args); |
||
| 41 | } |
||
| 42 | } elseif (preg_match('/^is?\:(.+?)\=/', $command, $matchs)) { |
||
| 43 | $module = $matchs[1]; |
||
| 44 | if (app()->getActiveModule() == app()->getModuleFullName($module)) { |
||
| 45 | return (new Command(preg_replace('/^.+?\=/', '', $command)))->exec($args); |
||
| 46 | } |
||
| 47 | } elseif (preg_match('/^(?:reachable)|r\:(.+?)\=/', $command, $matchs)) { |
||
| 48 | $module = $matchs[1]; |
||
| 49 | if (app()->isModuleReachable($module)) { |
||
| 50 | return (new Command(preg_replace('/^.+?\=/', '', $command)))->exec($args); |
||
| 51 | } |
||
| 52 | } else { |
||
| 53 | return (new Command($command))->exec($args); |
||
| 54 | } |
||
| 55 | } else { |
||
| 56 | return (new Command($command))->exec($args); |
||
| 57 | } |
||
| 60 |