| Conditions | 12 |
| Paths | 128 |
| Total Lines | 62 |
| Code Lines | 45 |
| Lines | 0 |
| Ratio | 0 % |
| Changes | 3 | ||
| Bugs | 0 | Features | 1 |
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 |
||
| 62 | function editCountdown($options) |
||
| 63 | { |
||
| 64 | $form = _MB_COUNTDOWN_EVENTTODISPLAY . ' ';; |
||
| 65 | $form .= "<input type='hidden' name='options[0]' value='" . $options[0] . "'> "; |
||
| 66 | $form .= "<select name='options[0]'>"; |
||
| 67 | $form .= "<option>" . _MB_COUNTDOWN_EVENTTODISPLAY . "</option>"; |
||
| 68 | |||
| 69 | $sql = "SELECT c.category_title,c.category_id,e.event_id,e.event_name,event_categoryid FROM " . $GLOBALS['xoopsDB']->prefix("countdown_events") . " AS e JOIN " . $GLOBALS['xoopsDB']->prefix("countdown_categories") . " AS c WHERE category_id=event_categoryid"; |
||
| 70 | $result = $GLOBALS['xoopsDB']->query($sql); |
||
| 71 | $totaldata = $GLOBALS['xoopsDB']->getRowsNum($result); |
||
| 72 | if ($totaldata > 0) { |
||
| 73 | while ($myrow = $GLOBALS['xoopsDB']->fetchArray($result)) { |
||
| 74 | $event[$myrow['category_title']][] = $myrow; |
||
| 75 | } |
||
| 76 | foreach ($event as $key => $values) { |
||
| 77 | $form .= '<optgroup label="' . $key . '">'; |
||
| 78 | foreach ($values as $value) { |
||
| 79 | if ($options[0] == $value['event_id']) { |
||
| 80 | $form .= '<option value="' . $options[0] . '" selected>' . $value['event_name'] . '</option>'; |
||
| 81 | } else { |
||
| 82 | $form .= '<option value="' . $value['event_id'] . '">' . $value['event_name'] . '</option>'; |
||
| 83 | } |
||
| 84 | } |
||
| 85 | $form .= "</optgroup>"; |
||
| 86 | } |
||
| 87 | } else { |
||
| 88 | } |
||
| 89 | $form .= "</select><br>"; |
||
| 90 | |||
| 91 | $form .= _MB_COUNTDOWN_DISPLAYEVENTDESCRIPTION . ' '; |
||
| 92 | if (1 == $options[1]) { |
||
| 93 | $chk = " checked"; |
||
| 94 | } |
||
| 95 | $form .= "<input type='radio' name='options[1]' value='1'" . $chk . ' > ' . _YES . ''; |
||
| 96 | $chk = ''; |
||
| 97 | if (0 == $options[1]) { |
||
| 98 | $chk = " checked"; |
||
| 99 | } |
||
| 100 | $form .= " <input type='radio' name='options[1]' value='0'" . $chk . ' >' . _NO . '<br>'; |
||
| 101 | |||
| 102 | $form .= _MB_COUNTDOWN_DISPLAYEVENTLOGO . ' '; |
||
| 103 | if (1 == $options[2]) { |
||
| 104 | $chk = " checked"; |
||
| 105 | } |
||
| 106 | $form .= "<input type='radio' name='options[2]' value='1'" . $chk . ' > ' . _YES . ''; |
||
| 107 | $chk = ''; |
||
| 108 | if (0 == $options[2]) { |
||
| 109 | $chk = " checked"; |
||
| 110 | } |
||
| 111 | $form .= " <input type='radio' name='options[2]' value='0'" . $chk . ' >' . _NO . '<br>'; |
||
| 112 | |||
| 113 | $form .= _MB_COUNTDOWN_DISPLAYINFO . ' '; |
||
| 114 | if (1 == $options[3]) { |
||
| 115 | $chk = " checked"; |
||
| 116 | } |
||
| 117 | $form .= "<input type='radio' name='options[3]' value='1'" . $chk . ' > ' . _YES . ''; |
||
| 118 | $chk = ''; |
||
| 119 | if (0 == $options[3]) { |
||
| 120 | $chk = " checked"; |
||
| 121 | } |
||
| 122 | $form .= " <input type='radio' name='options[3]' value='0'" . $chk . ' >' . _NO . '<br>'; |
||
| 123 | return $form; |
||
| 124 | } |
||
| 127 |