| Conditions | 11 |
| Paths | 11 |
| Total Lines | 62 |
| 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 |
||
| 68 | public function doStep(Order $order) |
||
| 69 | { |
||
| 70 | //if the order has been paid then do not worry about it at all! |
||
| 71 | if ($order->IsPaid()) { |
||
| 72 | return true; |
||
| 73 | } |
||
| 74 | //if the order has expired then cancel it ... |
||
| 75 | if ($this->isExpiredPaymentCheckStep($order)) { |
||
| 76 | //cancel order .... |
||
| 77 | if ($this->Config()->get("verbose")) { |
||
| 78 | DB::alteration_message(" - Time to send payment reminder is expired ... archive email"); |
||
| 79 | } |
||
| 80 | // cancel as admin ... |
||
| 81 | $member = EcommerceRole::get_default_shop_admin_user(); |
||
| 82 | $order->Cancel( |
||
| 83 | $member, |
||
| 84 | _t('OrderStep.CANCELLED_DUE_TO_NON_PAYMENT', 'Cancelled due to non-payment') |
||
| 85 | ); |
||
| 86 | |||
| 87 | return true; |
||
| 88 | } |
||
| 89 | //do we send at all? |
||
| 90 | elseif ($this->SendPaymentCheckEmail) { |
||
| 91 | //we can not send emails for pending payments, because pending payments can not be paid for ... |
||
| 92 | if ($order->PaymentIsPending()) { |
||
| 93 | return false; |
||
| 94 | } |
||
| 95 | //is now the right time to send? |
||
| 96 | if ($this->isReadyToGo($order)) { |
||
| 97 | $subject = $this->EmailSubject; |
||
| 98 | $message = $this->CustomerMessage; |
||
| 99 | if ($this->hasBeenSent($order, false)) { |
||
| 100 | if ($this->Config()->get("verbose")) { |
||
| 101 | DB::alteration_message(" - already sent!"); |
||
| 102 | } |
||
| 103 | |||
| 104 | return true; //do nothing |
||
| 105 | } else { |
||
| 106 | if ($this->Config()->get("verbose")) { |
||
| 107 | DB::alteration_message(" - Sending it now!"); |
||
| 108 | } |
||
| 109 | return $order->sendEmail( |
||
| 110 | $this->getEmailClassName(), |
||
| 111 | $subject, |
||
| 112 | $message, |
||
| 113 | $resend = false, |
||
| 114 | $adminOnlyOrToEmail = false |
||
| 115 | ); |
||
| 116 | } |
||
| 117 | } |
||
| 118 | //wait until later.... |
||
| 119 | else { |
||
| 120 | if ($this->Config()->get("verbose")) { |
||
| 121 | DB::alteration_message(" - We need to wait until minimum number of days."); |
||
| 122 | } |
||
| 123 | |||
| 124 | return false; |
||
| 125 | } |
||
| 126 | } else { |
||
| 127 | return true; |
||
| 128 | } |
||
| 129 | } |
||
| 130 | |||
| 239 |
You can fix this by adding a namespace to your class:
When choosing a vendor namespace, try to pick something that is not too generic to avoid conflicts with other libraries.