Conditions | 4 |
Paths | 8 |
Total Lines | 55 |
Code 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 declare(strict_types=1); |
||
35 | function sendFriend($lid): void |
||
36 | { |
||
37 | global $xoopsDB, $xoopsTheme, $xoopsLogger; |
||
38 | $helper = Helper::getInstance(); |
||
39 | $idd = $idde = $iddee = ''; |
||
|
|||
40 | require_once XOOPS_ROOT_PATH . '/class/xoopsformloader.php'; |
||
41 | require_once XOOPS_ROOT_PATH . '/header.php'; |
||
42 | $GLOBALS['xoTheme']->addMeta('meta', 'robots', 'noindex, nofollow'); |
||
43 | |||
44 | $sql = 'SELECT lid, title, type FROM ' . $xoopsDB->prefix('adslight_listing') . " WHERE lid={$lid}"; |
||
45 | $result = $xoopsDB->query($sql); |
||
46 | if (!$xoopsDB->isResultSet($result)) { |
||
47 | \trigger_error("Query Failed! SQL: $sql- Error: " . $xoopsDB->error(), E_USER_ERROR); |
||
48 | } |
||
49 | [$lid, $title, $type] = $xoopsDB->fetchRow($result); |
||
50 | |||
51 | echo "<table width='100%' border='0' cellspacing='1' cellpadding='8'><tr class='bg4'><td valign='top'> |
||
52 | <strong>" . _ADSLIGHT_SENDTO . " {$lid} \"<strong>{$type} : {$title}</strong>\" " . _ADSLIGHT_FRIEND . "<br><br> |
||
53 | <form action=\"sendfriend.php\" method=post> |
||
54 | <input type=\"hidden\" name=\"lid\" value=\"{$lid}\" >"; |
||
55 | |||
56 | if ($GLOBALS['xoopsUser'] instanceof \XoopsUser) { |
||
57 | $idd = $GLOBALS['xoopsUser']->getVar('uname', 'E'); |
||
58 | $idde = $GLOBALS['xoopsUser']->getVar('email', 'E'); |
||
59 | } |
||
60 | |||
61 | echo " |
||
62 | <table width='99%' class='outer' cellspacing='1'> |
||
63 | <tr> |
||
64 | <td class='head' width='30%'>" . _ADSLIGHT_NAME . " </td> |
||
65 | <td class='even'><input class='textbox' type='text' name='yname' value='{$idd}' ></td> |
||
66 | </tr> |
||
67 | <tr> |
||
68 | <td class='head'>" . _ADSLIGHT_MAIL . " </td> |
||
69 | <td class='even'><input class='textbox' type='text' name='ymail' value='{$idde}' ></td> |
||
70 | </tr> |
||
71 | <tr> |
||
72 | <td class='head'>" . _ADSLIGHT_NAMEFR . " </td> |
||
73 | <td class='even'><input class='textbox' type='text' name='fname' ></td> |
||
74 | </tr> |
||
75 | <tr> |
||
76 | <td class='head'>" . _ADSLIGHT_MAILFR . " </td> |
||
77 | <td class='even'><input class='textbox' type='text' name='fmail' ></td> |
||
78 | </tr>"; |
||
79 | |||
80 | if ('1' === $helper->getConfig('adslight_use_captcha')) { |
||
81 | echo "<tr><td class='head'>" . _ADSLIGHT_CAPTCHA . " </td><td class='even'>"; |
||
82 | $jlm_captcha = new \XoopsFormCaptcha(_ADSLIGHT_CAPTCHA, 'xoopscaptcha', false); |
||
83 | echo $jlm_captcha->render(); |
||
84 | echo '</td></tr>'; |
||
85 | } |
||
86 | |||
87 | echo '</table><br> |
||
88 | <input type=hidden name=op value=MailAd> |
||
89 | <input type=submit value=' . _ADSLIGHT_SENDFR . '> |
||
90 | </form></td></tr></table>'; |
||
193 |