Conditions | 32 |
Paths | 118 |
Total Lines | 149 |
Code Lines | 84 |
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 namespace Hideyo\Ecommerce\Framework\Services\Order\Events\Handlers; |
||
21 | public function handle(OrderChangeStatus $event) |
||
22 | { |
||
23 | if($event->order->shop->wholesale) { |
||
24 | |||
25 | if ($event->status->send_email_to_customer) { |
||
26 | |||
27 | if ($event->status->orderStatusEmailTemplate) { |
||
28 | |||
29 | $destinationPath = storage_path() . "/app"; |
||
30 | $orderStatusEmailFromResult = GeneralSettingService::selectOneByShopIdAndName($event->order->shop_id, 'order-status-email-from'); |
||
31 | |||
32 | $orderStatusEmailFrom = '[email protected]'; |
||
33 | if ($orderStatusEmailFromResult) { |
||
34 | $orderStatusEmailFrom = $orderStatusEmailFromResult->value; |
||
35 | } |
||
36 | |||
37 | $orderStatusEmailNameResult = GeneralSettingService::selectOneByShopIdAndName($event->order->shop_id, 'order-status-email-name'); |
||
38 | |||
39 | $orderStatusEmailName = 'Phil & Phae B2B'; |
||
40 | if ($orderStatusEmailNameResult) { |
||
41 | $orderStatusEmailName = $orderStatusEmailNameResult->value; |
||
42 | } |
||
43 | |||
44 | |||
45 | $orderStatusEmailBcc = '[email protected]'; |
||
46 | $language = 'en'; |
||
47 | if(strtoupper($event->order->orderBillAddress->country) == 'NL') { |
||
48 | $language = 'nl'; |
||
49 | } |
||
50 | |||
51 | |||
52 | Mail::send('frontend.email.order-status', ['content' => Cart::replaceTags($event->status->orderStatusEmailTemplate->translate($language)->content, $event->order)], function ($message) use ($event, $destinationPath, $orderStatusEmailFrom, $orderStatusEmailName, $orderStatusEmailBcc, $language) { |
||
53 | $message->from($orderStatusEmailFrom, $orderStatusEmailName); |
||
54 | $message->to($event->order->client->email, $event->order->orderBillAddress->firstname)->subject(Cart::replaceTags($event->status->orderStatusEmailTemplate->translate($language)->subject, $event->order)); |
||
55 | |||
56 | if ($orderStatusEmailBcc) { |
||
57 | $message->bcc($orderStatusEmailBcc, $orderStatusEmailName); |
||
58 | } |
||
59 | |||
60 | if ($event->order and $event->status->attach_order_to_email) { |
||
61 | $pdfText = ""; |
||
62 | $sign = '€'; |
||
63 | if($event->order->client->usd) { |
||
64 | $sign = '$'; |
||
65 | } |
||
66 | |||
67 | |||
68 | $pdf = \PDF::loadView('admin.order.pdf-wholesale', array('order' => $event->order, 'sign' => $sign, 'pdfText' => $pdfText))->setPaper('a4', 'landscape'); |
||
69 | if (!File::exists($destinationPath.'/order/')) { |
||
70 | File::makeDirectory($destinationPath.'/order/', 0777, true); |
||
71 | } |
||
72 | |||
73 | $upload_success = $pdf->save($destinationPath.'/order/order-'.$event->order->generated_custom_order_id.'.pdf'); |
||
74 | $message->attach($destinationPath.'/order/order-'.$event->order->generated_custom_order_id.'.pdf'); |
||
75 | Notification::success('Email has order attachment'); |
||
76 | } |
||
77 | |||
78 | Notification::success('Email with order status has been sent to '.$event->order->client->email.' from info@'.$orderStatusEmailFrom); |
||
79 | }); |
||
80 | |||
81 | if ($event->status->attach_order_to_email) { |
||
82 | File::delete($destinationPath.'/order/order-'.$event->order->generated_custom_order_id.'.pdf'); |
||
83 | } |
||
84 | } |
||
85 | |||
86 | if($event->order->type == 'pre_order') { |
||
87 | |||
88 | }elseif($event->order->type == 'from_stock') { |
||
89 | |||
90 | } |
||
91 | |||
92 | } |
||
93 | |||
94 | } else { |
||
95 | if ($event->status->send_email_to_customer) { |
||
96 | if ($event->status->orderStatusEmailTemplate) { |
||
97 | $destinationPath = storage_path() . "/app"; |
||
98 | $orderStatusEmailFromResult = GeneralSettingService::selectOneByShopIdAndName($event->order->shop_id, 'order-status-email-from'); |
||
99 | |||
100 | $orderStatusEmailFrom = '[email protected]'; |
||
101 | if ($orderStatusEmailFromResult) { |
||
102 | $orderStatusEmailFrom = $orderStatusEmailFromResult->value; |
||
103 | } |
||
104 | |||
105 | $orderStatusEmailNameResult = GeneralSettingService::selectOneByShopIdAndName($event->order->shop_id, 'order-status-email-name'); |
||
106 | |||
107 | $orderStatusEmailName = 'Phil & Phae'; |
||
108 | if ($orderStatusEmailNameResult) { |
||
109 | $orderStatusEmailName = $orderStatusEmailNameResult->value; |
||
110 | } |
||
111 | |||
112 | $orderStatusEmailBccResult = GeneralSettingService::selectOneByShopIdAndName($event->order->shop_id, 'order-status-email-bcc'); |
||
113 | $orderStatusEmailBcc = false; |
||
114 | |||
115 | if ($orderStatusEmailBccResult) { |
||
116 | $orderStatusEmailBcc = $orderStatusEmailBccResult->value; |
||
117 | } |
||
118 | |||
119 | $language = 'en'; |
||
120 | if(strtoupper($event->order->orderBillAddress->country) == 'NL') { |
||
121 | $language = 'nl'; |
||
122 | } |
||
123 | |||
124 | Mail::send('frontend.email.order-status', ['content' => Cart::replaceTags($event->status->orderStatusEmailTemplate->translate($language)->content, $event->order)], function ($message) use ($event, $destinationPath, $orderStatusEmailFrom, $orderStatusEmailName, $orderStatusEmailBcc, $language) { |
||
125 | $message->from($orderStatusEmailFrom, $orderStatusEmailName); |
||
126 | $message->to($event->order->client->email, $event->order->orderBillAddress->firstname)->subject(Cart::replaceTags($event->status->orderStatusEmailTemplate->translate($language)->subject, $event->order)); |
||
127 | |||
128 | if ($orderStatusEmailBcc) { |
||
129 | $message->bcc($orderStatusEmailBcc, $orderStatusEmailName); |
||
130 | } |
||
131 | |||
132 | if ($event->order->invoice and $event->status->attach_invoice_to_email) { |
||
133 | $pdf = \PDF::loadView('admin.invoice.pdf-consumer', array('invoice' => InvoiceService::find($event->order->invoice->id))); |
||
134 | if (!File::exists($destinationPath.'/invoice/')) { |
||
135 | File::makeDirectory($destinationPath.'/invoice/', 0777, true); |
||
136 | } |
||
137 | |||
138 | $upload_success = $pdf->save($destinationPath.'/invoice/invoice-'.$event->order->invoice->generated_custom_invoice_id.'.pdf'); |
||
139 | $message->attach($destinationPath.'/invoice/invoice-'.$event->order->invoice->generated_custom_invoice_id.'.pdf'); |
||
140 | Notification::success('Email has invoice attachment'); |
||
141 | } |
||
142 | |||
143 | if ($event->order and $event->status->attach_order_to_email) { |
||
144 | $text = $this->sendingPaymentMethodRelated->selectOneByShopIdAndPaymentMethodIdAndSendingMethodId($event->order->shop->id, $event->order->orderPaymentMethod->payment_method_id, $event->order->orderSendingMethod->sending_method_id); |
||
145 | |||
146 | $pdfText = ""; |
||
147 | if ($text) { |
||
148 | $pdfText = Cart::replaceTags($text->pdf_text, $event->order); |
||
149 | } |
||
150 | |||
151 | $pdf = \PDF::loadView('admin.order.pdf', array('order' => $event->order, 'pdfText' => $pdfText)); |
||
152 | if (!File::exists($destinationPath.'/order/')) { |
||
153 | File::makeDirectory($destinationPath.'/order/', 0777, true); |
||
154 | } |
||
155 | |||
156 | $upload_success = $pdf->save($destinationPath.'/order/order-'.$event->order->generated_custom_order_id.'.pdf'); |
||
157 | $message->attach($destinationPath.'/order/order-'.$event->order->generated_custom_order_id.'.pdf'); |
||
158 | Notification::success('Email has order attachment'); |
||
159 | } |
||
160 | |||
161 | Notification::success('Email with order status has been sent to '.$event->order->client->email.' from info@'.$orderStatusEmailFrom); |
||
162 | }); |
||
163 | |||
164 | if ($event->status->attach_invoice_to_email AND $event->order->invoice) { |
||
165 | File::delete($destinationPath.'/invoice/invoice-'.$event->order->invoice->generated_custom_invoice_id.'.pdf'); |
||
166 | } |
||
167 | |||
168 | if ($event->status->attach_order_to_email) { |
||
169 | File::delete($destinationPath.'/order/order-'.$event->order->generated_custom_order_id.'.pdf'); |
||
170 | } |
||
175 | } |
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