Conditions | 11 |
Paths | 8 |
Total Lines | 111 |
Code Lines | 88 |
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 |
||
65 | function showsubscription() |
||
66 | { |
||
67 | global $xoopsDB, $eh, $myts, $moddir, $get_itemid, $owner, $xoopsOption, $xoopsTpl, $subscription, $xoopsUser; |
||
68 | //Check if item selected. |
||
69 | if ($get_itemid == '0') { |
||
70 | redirect_header('index.php', 2, _MD_NOVALIDITEM); |
||
71 | exit(); |
||
72 | } |
||
73 | |||
74 | //Default function (if listing type is normal) would be to view the possible subscriptions. |
||
75 | |||
76 | //Show current subscription order for listing |
||
77 | $defaultstartdate = time(); |
||
78 | $sql = 'SELECT i.title, i.typeid, o.orderid, o.offerid, o.startdate, o.enddate, o.billto, o.status, o.itemid, o.autorenew, t.typename, p.ref, p.payment_status FROM ' |
||
79 | . $xoopsDB->prefix($module->getVar('dirname', 'n') . '_itemtypes') |
||
80 | . ' t, ' |
||
81 | . $xoopsDB->prefix($module->getVar('dirname', 'n') . '_items') |
||
82 | . ' i, ' |
||
83 | . $xoopsDB->prefix($module->getVar('dirname', 'n') . '_subscr_orders') |
||
84 | . ' o LEFT JOIN ' |
||
85 | . $xoopsDB->prefix($module->getVar('dirname', 'n') . '_subscr_payments') |
||
86 | . ' p ON (o.orderid=p.orderid) WHERE o.typeid = t.typeid AND o.itemid=p.ref AND o.itemid=i.itemid AND i.itemid=' |
||
87 | . $get_itemid |
||
88 | . ' ORDER BY t.typelevel ASC'; |
||
89 | $item_result = $xoopsDB->query($sql) or $eh->show('0013'); |
||
90 | $numrows = $xoopsDB->getRowsNum($item_result); |
||
91 | $order_exists = false; |
||
92 | if ($numrows > 0) { |
||
93 | $xoopsTpl->assign('order_table', true); |
||
94 | while (list($title, $typeid, $orderid, $offerid, $startdate, $enddate, $billto, $orderstatus, $itemid, $autorenew, $typename, $ref, $paymentstatus) = $xoopsDB->fetchRow($item_result)) { |
||
95 | //Assign the text of the label for subscription type. |
||
96 | $ordername = $subscription->getOrderItemName($offerid); |
||
97 | |||
98 | if ($paymentstatus == '') { |
||
99 | $paymentstatus = _MD_LANG_INCOMPLETE; |
||
100 | $terminate_on = '1'; |
||
101 | } else { |
||
102 | $terminate_on = null; |
||
103 | $order_exists = true; |
||
104 | } |
||
105 | if ($orderstatus == '1') { |
||
106 | $defaultstartdate = $billto; |
||
107 | } |
||
108 | if ($billto != '') { |
||
109 | $billto = date('d-M-Y', $billto); |
||
110 | } |
||
111 | if ($enddate != '') { |
||
112 | $enddate = date('d-M-Y', $enddate); |
||
113 | } |
||
114 | if ($startdate != '') { |
||
115 | $startdate = date('d-M-Y', $startdate); |
||
116 | } |
||
117 | $xoopsTpl->assign('lang_subscr_offers_header', _MD_LANG_SUBSCR_ACTIVE_ORDERS_HEADER); |
||
118 | $xoopsTpl->append('active_orders', array( |
||
119 | 'orderid' => $orderid, |
||
120 | 'ordername' => $ordername, |
||
121 | 'offerid' => $offerid, |
||
122 | 'startdate' => $startdate, |
||
123 | 'enddate' => $enddate, |
||
124 | 'billto' => $billto, |
||
125 | 'orderstatus' => $orderstatus, |
||
126 | 'itemid' => $itemid, |
||
127 | 'autorenew' => $autorenew, |
||
128 | 'typename' => $myts->htmlSpecialChars($typename), |
||
129 | 'ref' => $ref, |
||
130 | 'paymentstatus' => $paymentstatus, |
||
131 | 'renewal_url' => "subscriptions.php?op=renew&order=$orderid&item=$get_itemid", |
||
132 | 'terminate_url' => "subscriptions.php?op=terminate&order=$orderid&item=$get_itemid", |
||
133 | 'terminate_on' => $terminate_on |
||
134 | )); |
||
135 | $xoopsTpl->assign('lang_current_subscr', _MD_LANG_CURRENT_SUBSCR); |
||
136 | $xoopsTpl->assign('current_subscr', $typename); |
||
137 | $xoopsTpl->assign('lang_terminate_order', _MD_LANG_TERMINATE_ORDER); |
||
138 | $xoopsTpl->assign('lang_terminate_order_alt', _MD_LANG_TERMINATE_ORDER_ALT); |
||
139 | $xoopsTpl->assign('lang_renew_subscription', _MD_LANG_RENEW_SUBSCRIPTION); |
||
140 | $xoopsTpl->assign('lang_renew_subscription_alt', _MD_LANG_RENEW_SUBSCRIPTION_ALT); |
||
141 | //$xoopsTpl->assign('renewal_url', "subscriptions.php?op=renew"); |
||
142 | |||
143 | $xoopsTpl->assign('lang_ordername', _MD_LANG_ORDERNAME); |
||
144 | $xoopsTpl->assign('lang_startdate', _MD_LANG_STARTDATE); |
||
145 | $xoopsTpl->assign('lang_billtodate', _MD_LANG_BILLTO); |
||
146 | $xoopsTpl->assign('lang_enddate', _MD_LANG_ENDDATE); |
||
147 | $xoopsTpl->assign('lang_paymentstatus', _MD_LANG_PAYMENTSTATUS); |
||
148 | $xoopsTpl->assign('lang_actions', _MD_LANG_ACTIONS); |
||
149 | $xoopsTpl->assign('moddir', $moddir); |
||
150 | $listingtitle = $myts->htmlSpecialChars($title); |
||
151 | } |
||
152 | } else { |
||
153 | $xoopsTpl->assign('lang_no_subscr_moment', _MD_LANG_NO_SUBSCR_MOMENT); |
||
154 | } |
||
155 | ob_start(); |
||
156 | if ($order_exists) { |
||
157 | $order_form_title = _MD_UPDATE_SUBSCR_FORM; |
||
158 | } else { |
||
159 | $order_form_title = _MD_SUBSCR_FORM; |
||
160 | } |
||
161 | $form = new XoopsThemeForm($order_form_title, 'subscribeform', 'subscriptions.php?item=' . $get_itemid . ''); |
||
162 | $duration_arr = $subscription->durationPriceArray('1'); |
||
163 | $itemtype_select = new efqFormRadio(_MD_SUBSCR_TYPE, 'typeofferid', null, '<br>'); |
||
164 | $itemtype_select->addOptionArray($duration_arr); |
||
165 | $form->addElement($itemtype_select, true); |
||
166 | //TO DO: Add Auto Renew functionality |
||
167 | //$form->addElement(new XoopsFormRadioYN(_MD_AUTORENEWYN, 'autorenewal', '1'),true); |
||
168 | $form->addElement(new XoopsFormTextDateSelect(_MD_SELECT_STARTDATE, 'startdate', 15, $defaultstartdate), true); |
||
169 | $form->addElement(new XoopsFormButton('', 'submit', _MD_CONTINUE, 'submit')); |
||
170 | $form->addElement(new XoopsFormHidden('op', 'orderselect')); |
||
171 | $form->addElement(new XoopsFormHidden('uid', $xoopsUser->getVar('uid'))); |
||
172 | $form->display(); |
||
173 | $orderform = ob_get_contents(); |
||
174 | ob_end_clean(); |
||
175 | $xoopsTpl->assign('orderform', $orderform); |
||
176 | } |
||
357 |
The issue could also be caused by a filter entry in the build configuration. If the path has been excluded in your configuration, e.g.
excluded_paths: ["lib/*"]
, you can move it to the dependency path list as follows:For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths