| Conditions | 9 |
| Paths | 64 |
| Total Lines | 74 |
| Code Lines | 53 |
| Lines | 11 |
| Ratio | 14.86 % |
| 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 |
||
| 44 | * @return array |
||
| 45 | */ |
||
| 46 | function b_donations_donate_show($options) |
||
| 47 | { |
||
| 48 | global $xoopsDB, $xoopsUser; |
||
| 49 | |||
| 50 | $moduleDirName = basename(dirname(__DIR__)); |
||
| 51 | $utility = new Xdonations\Utility(); |
||
| 52 | $tr_config = $utility::getConfigInfo(); |
||
| 53 | $paypal_url = explode('|', $tr_config['paypal_url']); |
||
| 54 | $paypal_url = $paypal_url[0]; |
||
| 55 | //determine the currency |
||
| 56 | $PP_CURR_CODE = explode('|', $tr_config['pp_curr_code']); // [USD,GBP,JPY,CAD,EUR] |
||
| 57 | $PP_CURR_CODE = $PP_CURR_CODE[0]; |
||
| 58 | $currencySign = $utility::defineCurrency($PP_CURR_CODE); |
||
| 59 | |||
| 60 | $block = []; |
||
| 61 | |||
| 62 | $PP_RECEIVER_EMAIL = $tr_config['receiver_email']; |
||
| 63 | $PP_ITEMNAME = $tr_config['pp_itemname']; |
||
| 64 | $PP_TY_URL = $tr_config['ty_url']; |
||
| 65 | $PP_CANCEL_URL = $tr_config['pp_cancel_url']; |
||
| 66 | |||
| 67 | // Fill out some more template tags |
||
| 68 | $DON_BUTTON_SUBMIT = $tr_config['don_button_submit']; |
||
| 69 | |||
| 70 | $PP_NO_SHIP = $tr_config['pp_get_addr'] ? '0' : '1'; |
||
| 71 | $PP_IMAGE_URL = $tr_config['pp_image_url']; |
||
| 72 | |||
| 73 | $DON_SUB_IMG_DIMS = ''; |
||
| 74 | if (is_numeric($tr_config['don_sub_img_width'])) { |
||
| 75 | $DON_SUB_IMG_DIMS .= 'width=' . $tr_config['don_sub_img_width'] . ' '; |
||
| 76 | } |
||
| 77 | if (is_numeric($tr_config['don_sub_img_height'])) { |
||
| 78 | $DON_SUB_IMG_DIMS .= 'height=' . $tr_config['don_sub_img_height'] . ' '; |
||
| 79 | } |
||
| 80 | |||
| 81 | $sql = 'SELECT * FROM ' . $xoopsDB->prefix('donations_config') . " WHERE name='don_amount' ORDER BY subtype"; |
||
| 82 | $Recordset1 = $xoopsDB->query($sql); |
||
| 83 | |||
| 84 | $DONATION_AMOUNTS = ''; |
||
| 85 | while (false !== ($row_Recordset1 = $xoopsDB->fetchArray($Recordset1))) { |
||
| 86 | if (is_numeric($row_Recordset1['value']) && $row_Recordset1['value'] > 0) { |
||
| 87 | if ($row_Recordset1['subtype'] == $tr_config['don_amt_checked']) { |
||
| 88 | $checked = ' selected'; |
||
| 89 | $block['basedonation'] = $row_Recordset1['value']; |
||
| 90 | } else { |
||
| 91 | $checked = ''; |
||
| 92 | } |
||
| 93 | $DONATION_AMOUNTS .= '<option value="' . $row_Recordset1['value'] . '" ' . $checked . ' > ' . $currencySign . $row_Recordset1['value'] . '</option>' . "\n"; |
||
| 94 | } |
||
| 95 | } |
||
| 96 | $DONATION_AMOUNTS .= '<option value="0"> ' . _MB_XDONATION_OTHER_AMOUNT . ' </option>'; |
||
| 97 | |||
| 98 | // Ok, output the page |
||
| 99 | |||
| 100 | $uid = $xoopsUser ? $xoopsUser->getVar('uid') : 0; |
||
| 101 | $block['custom'] = $uid; |
||
| 102 | $block['email'] = $PP_RECEIVER_EMAIL; |
||
| 103 | $block['item'] = $PP_ITEMNAME; |
||
| 104 | $block['amounts'] = $DONATION_AMOUNTS; |
||
| 105 | $block['prompt'] = $tr_config['don_name_prompt']; |
||
| 106 | $block['nm_yes'] = $tr_config['don_name_yes']; |
||
| 107 | $block['nm_no'] = $tr_config['don_name_no']; |
||
| 108 | $block['pp_noship'] = $PP_NO_SHIP; |
||
| 109 | $block['pp_curr_code'] = $PP_CURR_CODE; |
||
| 110 | $block['pp_cancel'] = $PP_CANCEL_URL; |
||
| 111 | $block['pp_thanks'] = $PP_TY_URL; |
||
| 112 | $block['pp_image'] = $PP_IMAGE_URL; |
||
| 113 | $block['sub_img'] = $DON_SUB_IMG_DIMS; |
||
| 114 | $block['submit_button'] = _MB_XDONATION_SUBMIT_BUTTON; |
||
| 115 | $block['paypal_url'] = $paypal_url; |
||
| 116 | $block['lang_select'] = _MB_XDONATION_SELECTAMT; |
||
| 117 | $block['xdon_dir'] = $moduleDirName; |
||
| 118 | |||
| 121 |