| Conditions | 11 |
| Paths | 11 |
| Total Lines | 31 |
| 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 |
||
| 57 | public function deleteAccount($userid) |
||
| 58 | { |
||
| 59 | $user = new \XoopsUser($userid); |
||
|
|
|||
| 60 | //$username = $user->uname(); |
||
| 61 | $sql01 = 'DELETE FROM ' . $GLOBALS['xoopsDB']->prefix('smallworld_admin') . " WHERE userid = '" . $userid . "'"; |
||
| 62 | $sql02 = 'DELETE FROM ' . $GLOBALS['xoopsDB']->prefix('smallworld_comments') . " WHERE uid_fk = '" . $userid . "'"; |
||
| 63 | $sql03 = 'DELETE FROM ' . $GLOBALS['xoopsDB']->prefix('smallworld_followers') . " WHERE me = '" . $userid . "' OR you = '" . $userid . "'"; |
||
| 64 | $sql04 = 'DELETE FROM ' . $GLOBALS['xoopsDB']->prefix('smallworld_friends') . " WHERE me = '" . $userid . "' OR you = '" . $userid . "'"; |
||
| 65 | $sql05 = 'DELETE FROM ' . $GLOBALS['xoopsDB']->prefix('smallworld_images') . " WHERE userid = '" . $userid . "'"; |
||
| 66 | $sql06 = 'DELETE FROM ' . $GLOBALS['xoopsDB']->prefix('smallworld_messages') . " WHERE uid_fk = '" . $userid . "'"; |
||
| 67 | $sql07 = 'DELETE FROM ' . $GLOBALS['xoopsDB']->prefix('smallworld_user') . " WHERE userid = '" . $userid . "'"; |
||
| 68 | $sql08 = 'DELETE FROM ' . $GLOBALS['xoopsDB']->prefix('smallworld_vote') . " WHERE user_id = '" . $userid . "'"; |
||
| 69 | $sql09 = 'DELETE FROM ' . $GLOBALS['xoopsDB']->prefix('smallworld_complaints') . " WHERE owner = '" . $userid . "' OR byuser_id = '" . $userid . "'"; |
||
| 70 | $sql10 = 'DELETE FROM ' . $GLOBALS['xoopsDB']->prefix('smallworld_settings') . " WHERE userid = '" . $userid . "'"; |
||
| 71 | |||
| 72 | $result01 = $GLOBALS['xoopsDB']->queryF($sql01); |
||
| 73 | $result02 = $GLOBALS['xoopsDB']->queryF($sql02); |
||
| 74 | $result03 = $GLOBALS['xoopsDB']->queryF($sql03); |
||
| 75 | $result04 = $GLOBALS['xoopsDB']->queryF($sql04); |
||
| 76 | $result05 = $GLOBALS['xoopsDB']->queryF($sql05); |
||
| 77 | $result06 = $GLOBALS['xoopsDB']->queryF($sql06); |
||
| 78 | $result07 = $GLOBALS['xoopsDB']->queryF($sql07); |
||
| 79 | $result08 = $GLOBALS['xoopsDB']->queryF($sql08); |
||
| 80 | $result09 = $GLOBALS['xoopsDB']->queryF($sql09); |
||
| 81 | $result10 = $GLOBALS['xoopsDB']->queryF($sql10); |
||
| 82 | // Remove picture dir |
||
| 83 | $dirname = XOOPS_ROOT_PATH . '/uploads/albums_smallworld' . '/' . $userid . '/'; |
||
| 84 | $result11 = $this->smallworld_remDir($userid, $dirname, $empty = false); |
||
| 85 | |||
| 86 | return $result01 && $result02 && $result03 && $result04 && $result05 && $result06 && $result07 && $result08 && $result09 && $result10 && $result11; |
||
| 87 | } |
||
| 88 | |||
| 161 |
This check looks for variable assignements that are either overwritten by other assignments or where the variable is not used subsequently.
Both the
$myVarassignment in line 1 and the$higherassignment in line 2 are dead. The first because$myVaris never used and the second because$higheris always overwritten for every possible time line.