Conditions | 11 |
Paths | 25 |
Total Lines | 56 |
Code Lines | 34 |
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 |
||
82 | public function sendNotification($order) |
||
83 | { |
||
84 | // Deal with customer email |
||
85 | if ($order->Email && ($this->SendNotificationTo == 'Customer' || $this->SendNotificationTo == "Both")) { |
||
86 | if ($this->CustomSubject) { |
||
87 | $subject = $this->CustomSubject; |
||
88 | } else { |
||
89 | $subject = _t('Orders.Order', 'Order') . " {$order->OrderNumber} {$order->Status}"; |
||
90 | } |
||
91 | |||
92 | $email = Email::create() |
||
93 | ->setSubject($subject) |
||
94 | ->setTo($order->Email) |
||
95 | ->setHTMLTemplate("\\SilverCommerce\\OrdersAdmin\\Email\\OrderNotificationEmail_Customer") |
||
96 | ->setData([ |
||
97 | "Order" => $order, |
||
98 | "SiteConfig" => $this->Parent(), |
||
99 | "Notification" => $this |
||
100 | ]); |
||
101 | |||
102 | if ($this->FromEmail) { |
||
103 | $email->setFrom($this->FromEmail); |
||
104 | } |
||
105 | |||
106 | $this->extend("augmentEmailCustomer", $email, $order); |
||
107 | |||
108 | $email->send(); |
||
109 | } |
||
110 | |||
111 | // Deal with vendor email |
||
112 | if ($this->VendorEmail && ($this->SendNotificationTo == 'Vendor' || $this->SendNotificationTo == "Both")) { |
||
113 | if ($this->CustomSubject) { |
||
114 | $subject = $this->CustomSubject; |
||
115 | } else { |
||
116 | $subject = _t('Orders.Order', 'Order') . " {$order->OrderNumber} {$order->Status}"; |
||
117 | } |
||
118 | |||
119 | $email = Email::create() |
||
120 | ->setSubject($subject) |
||
121 | ->setTo($this->VendorEmail) |
||
122 | ->setHTMLTemplate("\\SilverCommerce\\OrdersAdmin\\Email\\OrderNotificationEmail_Vendor") |
||
123 | ->setData([ |
||
124 | "Order" => $order, |
||
125 | "Notification" => $this |
||
126 | ]); |
||
127 | |||
128 | if ($this->FromEmail) { |
||
129 | $email->setFrom($this->FromEmail); |
||
130 | } |
||
131 | |||
132 | $this->extend("augmentEmailVendor", $email, $order); |
||
133 | |||
134 | $email->send(); |
||
135 | } |
||
136 | |||
137 | $this->extend("augmentSend", $order); |
||
138 | } |
||
140 |