| Conditions | 11 |
| Paths | 4 |
| Total Lines | 29 |
| Code Lines | 19 |
| 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 declare(strict_types=1); |
||
| 26 | function xoops_module_update_vs_executesql($sql): bool |
||
| 27 | { |
||
| 28 | if (is_string($sql)) { |
||
| 29 | if ($GLOBALS['xoopsDB']->queryF($sql)) { |
||
| 30 | xoops_error($sql, 'SQL Executed Successfully!!!'); |
||
| 31 | } |
||
| 32 | } elseif (is_array($sql)) { |
||
| 33 | foreach ($sql as $id => $question) { |
||
| 34 | if (is_array($question)) { |
||
| 35 | foreach ($question as $kquestion => $questionb) { |
||
| 36 | if ($GLOBALS['xoopsDB']->queryF($kquestion)) { |
||
| 37 | xoops_error($kquestion, 'SQL Executed Successfully!!!'); |
||
| 38 | xoops_module_update_vs_executesql($questionb); |
||
| 39 | } |
||
| 40 | } |
||
| 41 | } elseif ($GLOBALS['xoopsDB']->queryF($id)) { |
||
| 42 | xoops_error($id, 'SQL Executed Successfully!!!'); |
||
| 43 | if ($GLOBALS['xoopsDB']->queryF($question)) { |
||
| 44 | xoops_error($question, 'SQL Executed Successfully!!!'); |
||
| 45 | } |
||
| 46 | } elseif ($GLOBALS['xoopsDB']->queryF($question)) { |
||
| 47 | xoops_error($question, 'SQL Executed Successfully!!!'); |
||
| 48 | } |
||
| 49 | } |
||
| 50 | } else { |
||
| 51 | return false; |
||
| 52 | } |
||
| 53 | |||
| 54 | return true; |
||
| 55 | } |
||
| 56 |
This check looks for parameters that have been defined for a function or method, but which are not used in the method body.