Conditions | 10 |
Paths | 129 |
Total Lines | 56 |
Code Lines | 37 |
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 |
||
31 | public function getUserbar() |
||
32 | { |
||
33 | global $xoopsModuleConfig, $xoopsUser, $isadmin; |
||
34 | if (empty($GLOBALS['xoopsModuleConfig']['userbar_enabled'])) { |
||
35 | return null; |
||
36 | } |
||
37 | $user = $this->user; |
||
38 | $userbar = []; |
||
39 | $userbar[] = [ |
||
40 | 'link' => $GLOBALS['xoops']->url('userinfo.php?uid=' . $user->getVar('uid')), |
||
41 | 'name' => PROFILE |
||
|
|||
42 | ]; |
||
43 | if (is_object($xoopsUser)) { |
||
44 | $userbar[] = [ |
||
45 | 'link' => "javascript:void openWithSelfMain('" . XOOPS_URL . '/pmlite.php?send2=1&to_userid=' . $user->getVar('uid') . "','pmlite', 450, 380);", |
||
46 | 'name' => _MD_PM |
||
47 | ]; |
||
48 | } |
||
49 | if ($user->getVar('user_viewemail') || $isadmin) { |
||
50 | $userbar[] = [ |
||
51 | 'link' => "javascript:void window.open('mailto:" . $user->getVar('email') . "','new');", |
||
52 | 'name' => _MD_EMAIL |
||
53 | ]; |
||
54 | } |
||
55 | if ($user->getVar('url')) { |
||
56 | $userbar[] = [ |
||
57 | 'link' => "javascript:void window.open('" . $user->getVar('url') . "','new');", |
||
58 | 'name' => _MD_WWW |
||
59 | ]; |
||
60 | } |
||
61 | if ($user->getVar('user_icq')) { |
||
62 | $userbar[] = [ |
||
63 | 'link' => "javascript:void window.open('http://wwp.icq.com/scripts/search.dll?to=" . $user->getVar('user_icq') . "','new');", |
||
64 | 'name' => _MD_ICQ |
||
65 | ]; |
||
66 | } |
||
67 | if ($user->getVar('user_aim')) { |
||
68 | $userbar[] = [ |
||
69 | 'link' => "javascript:void window.open('aim:goim?screenname=" . $user->getVar('user_aim') . '&message=Hi+' . $user->getVar('user_aim') . '+Are+you+there?' . "','new');", |
||
70 | 'name' => _MD_AIM |
||
71 | ]; |
||
72 | } |
||
73 | if ($user->getVar('user_yim')) { |
||
74 | $userbar[] = [ |
||
75 | 'link' => "javascript:void window.open('http://edit.yahoo.com/config/send_webmesg?.target=" . $user->getVar('user_yim') . '&.src=pg' . "','new');", |
||
76 | 'name' => _MD_YIM |
||
77 | ]; |
||
78 | } |
||
79 | if ($user->getVar('user_msnm')) { |
||
80 | $userbar[] = [ |
||
81 | 'link' => "javascript:void window.open('http://members.msn.com?mem=" . $user->getVar('user_msnm') . "','new');", |
||
82 | 'name' => _MD_MSNM |
||
83 | ]; |
||
84 | } |
||
85 | |||
86 | return $userbar; |
||
87 | } |
||
89 |