Conditions | 3 |
Paths | 4 |
Total Lines | 53 |
Code Lines | 28 |
Lines | 7 |
Ratio | 13.21 % |
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 |
||
29 | function SendFriend($lid) |
||
1 ignored issue
–
show
|
|||
30 | { |
||
31 | global $xoopsConfig, $xoopsDB, $xoopsTheme, $xoopsLogger, $moduleDirName, $main_lang; |
||
1 ignored issue
–
show
|
|||
32 | |||
33 | include XOOPS_ROOT_PATH . '/class/xoopsformloader.php'; |
||
34 | include XOOPS_ROOT_PATH . '/header.php'; |
||
35 | $xoTheme->addMeta('meta', 'robots', 'noindex, nofollow'); |
||
36 | |||
37 | $result = $xoopsDB->query('SELECT lid, title, type FROM ' . $xoopsDB->prefix('adslight_listing') . " WHERE lid={$lid}"); |
||
38 | list($lid, $title, $type) = $xoopsDB->fetchRow($result); |
||
39 | |||
40 | echo "<table width='100%' border='0' cellspacing='1' cellpadding='8'><tr class='bg4'><td valign='top'> |
||
41 | <strong>" . _ADSLIGHT_SENDTO . " $lid \"<strong>$type : $title</strong>\" " . _ADSLIGHT_FRIEND . "<br><br> |
||
42 | <form action=\"sendfriend.php\" method=post> |
||
43 | <input type=\"hidden\" name=\"lid\" value=\"$lid\" />"; |
||
44 | |||
45 | if ($GLOBALS['xoopsUser'] instanceof XoopsUser) { |
||
46 | $idd = $GLOBALS['xoopsUser']->getVar('uname', 'E'); |
||
47 | $idde = $GLOBALS['xoopsUser']->getVar('email', 'E'); |
||
48 | } |
||
49 | |||
50 | echo " |
||
51 | <table width='99%' class='outer' cellspacing='1'> |
||
52 | <tr> |
||
53 | <td class='head' width='30%'>" . _ADSLIGHT_NAME . " </td> |
||
54 | <td class='even'><input class='textbox' type='text' name='yname' value='$idd' /></td> |
||
55 | </tr> |
||
56 | <tr> |
||
57 | <td class='head'>" . _ADSLIGHT_MAIL . " </td> |
||
58 | <td class='even'><input class='textbox' type='text' name='ymail' value='$idde' /></td> |
||
59 | </tr> |
||
60 | <tr> |
||
61 | <td class='head'>" . _ADSLIGHT_NAMEFR . " </td> |
||
62 | <td class='even'><input class='textbox' type='text' name='fname' /></td> |
||
63 | </tr> |
||
64 | <tr> |
||
65 | <td class='head'>" . _ADSLIGHT_MAILFR . " </td> |
||
66 | <td class='even'><input class='textbox' type='text' name='fmail' /></td> |
||
67 | </tr>"; |
||
68 | |||
69 | View Code Duplication | if ($GLOBALS['xoopsModuleConfig']['adslight_use_captcha'] == '1') { |
|
1 ignored issue
–
show
|
|||
70 | echo "<tr><td class='head'>" . _ADSLIGHT_CAPTCHA . " </td><td class='even'>"; |
||
71 | $jlm_captcha = ''; |
||
72 | $jlm_captcha = new XoopsFormCaptcha(_ADSLIGHT_CAPTCHA, 'xoopscaptcha', false); |
||
73 | echo $jlm_captcha->render(); |
||
74 | echo '</td></tr>'; |
||
75 | } |
||
76 | |||
77 | echo '</table><br> |
||
78 | <input type=hidden name=op value=MailAd> |
||
79 | <input type=submit value=' . _ADSLIGHT_SENDFR . '> |
||
80 | </form></td></tr></table>'; |
||
81 | } |
||
82 | |||
186 |
The PSR-1: Basic Coding Standard recommends that a file should either introduce new symbols, that is classes, functions, constants or similar, or have side effects. Side effects are anything that executes logic, like for example printing output, changing ini settings or writing to a file.
The idea behind this recommendation is that merely auto-loading a class should not change the state of an application. It also promotes a cleaner style of programming and makes your code less prone to errors, because the logic is not spread out all over the place.
To learn more about the PSR-1, please see the PHP-FIG site on the PSR-1.