Conditions | 8 |
Paths | 32 |
Total Lines | 258 |
Code Lines | 33 |
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 |
||
161 | public function header( string $uid = '' ) : ?string |
||
162 | { |
||
163 | $config = $this->getContext()->config(); |
||
164 | $view = $this->object()->data( $this->view() ); |
||
165 | |||
166 | $content = ''; |
||
167 | foreach( $this->getSubClients() as $subclient ) { |
||
168 | $content .= $subclient->setView( $view )->header( $uid ); |
||
169 | } |
||
170 | $view->deliveryHeader = $content; |
||
171 | |||
172 | |||
173 | $addr = $view->extAddressItem; |
||
174 | |||
175 | $msg = $view->mail(); |
||
176 | $msg->header( 'X-MailGenerator', 'Aimeos' ); |
||
177 | $msg->to( $addr->getEMail(), $addr->getFirstName() . ' ' . $addr->getLastName() ); |
||
178 | |||
179 | $addresses = $view->extOrderBaseItem->getAddress( \Aimeos\MShop\Order\Item\Base\Address\Base::TYPE_PAYMENT ); |
||
180 | |||
181 | if( ( $billAddr = current( $addresses ) ) !== false && $billAddr->getEMail() != $addr->getEmail() ) { |
||
182 | $msg->cc( $billAddr->getEMail(), $billAddr->getFirstName() . ' ' . $billAddr->getLastName() ); |
||
183 | } |
||
184 | |||
185 | |||
186 | $fromName = $config->get( 'resource/email/from-name' ); |
||
187 | |||
188 | /** client/html/email/from-name |
||
189 | * Name used when sending e-mails |
||
190 | * |
||
191 | * The name of the person or e-mail account that is used for sending all |
||
192 | * shop related emails to customers. |
||
193 | * |
||
194 | * @param string Name shown in the e-mail |
||
195 | * @since 2014.03 |
||
196 | * @category User |
||
197 | * @see client/html/email/delivery/from-name |
||
198 | * @see client/html/email/from-email |
||
199 | * @see client/html/email/reply-email |
||
200 | * @see client/html/email/bcc-email |
||
201 | * @see resource/email/from-name |
||
202 | */ |
||
203 | $fromName = $config->get( 'client/html/email/from-name', $fromName ); |
||
204 | |||
205 | /** client/html/email/delivery/from-name |
||
206 | * Name used when sending delivery e-mails |
||
207 | * |
||
208 | * The name of the person or e-mail account that is used for sending all |
||
209 | * shop related delivery e-mails to customers. This configuration option |
||
210 | * overwrites the name set in "client/html/email/from-name". |
||
211 | * |
||
212 | * @param string Name shown in the e-mail |
||
213 | * @since 2014.03 |
||
214 | * @category User |
||
215 | * @see client/html/email/from-name |
||
216 | * @see client/html/email/from-email |
||
217 | * @see client/html/email/reply-email |
||
218 | * @see client/html/email/bcc-email |
||
219 | */ |
||
220 | $fromNameDelivery = $config->get( 'client/html/email/delivery/from-name', $fromName ); |
||
221 | |||
222 | $fromEmail = $config->get( 'resource/email/from-email' ); |
||
223 | |||
224 | /** client/html/email/from-email |
||
225 | * E-Mail address used when sending e-mails |
||
226 | * |
||
227 | * The e-mail address of the person or account that is used for sending |
||
228 | * all shop related emails to customers. |
||
229 | * |
||
230 | * @param string E-mail address |
||
231 | * @since 2014.03 |
||
232 | * @category User |
||
233 | * @see client/html/email/from-name |
||
234 | * @see client/html/email/delivery/from-email |
||
235 | * @see client/html/email/reply-email |
||
236 | * @see client/html/email/bcc-email |
||
237 | * @see resource/email/from-email |
||
238 | */ |
||
239 | $fromEmail = $config->get( 'client/html/email/from-email', $fromEmail ); |
||
240 | |||
241 | /** client/html/email/delivery/from-email |
||
242 | * E-Mail address used when sending delivery e-mails |
||
243 | * |
||
244 | * The e-mail address of the person or account that is used for sending |
||
245 | * all shop related delivery emails to customers. This configuration option |
||
246 | * overwrites the e-mail address set via "client/html/email/from-email". |
||
247 | * |
||
248 | * @param string E-mail address |
||
249 | * @since 2014.03 |
||
250 | * @category User |
||
251 | * @see client/html/email/delivery/from-name |
||
252 | * @see client/html/email/from-email |
||
253 | * @see client/html/email/reply-email |
||
254 | * @see client/html/email/bcc-email |
||
255 | */ |
||
256 | if( ( $fromEmailDelivery = $config->get( 'client/html/email/delivery/from-email', $fromEmail ) ) != null ) { |
||
257 | $msg->from( $fromEmailDelivery, $fromNameDelivery ); |
||
258 | } |
||
259 | |||
260 | |||
261 | /** client/html/email/reply-name |
||
262 | * Recipient name displayed when the customer replies to e-mails |
||
263 | * |
||
264 | * The name of the person or e-mail account the customer should |
||
265 | * reply to in case of questions or problems. If no reply name is |
||
266 | * configured, the name person or e-mail account set via |
||
267 | * "client/html/email/from-name" is used. |
||
268 | * |
||
269 | * @param string Name shown in the e-mail |
||
270 | * @since 2014.03 |
||
271 | * @category User |
||
272 | * @see client/html/email/reply-email |
||
273 | * @see client/html/email/delivery/reply-email |
||
274 | * @see client/html/email/from-email |
||
275 | * @see client/html/email/from-name |
||
276 | * @see client/html/email/bcc-email |
||
277 | */ |
||
278 | $replyName = $config->get( 'client/html/email/reply-name', $fromName ); |
||
279 | |||
280 | /** client/html/email/delivery/reply-name |
||
281 | * Recipient name displayed when the customer replies to delivery e-mails |
||
282 | * |
||
283 | * The name of the person or e-mail account the customer should |
||
284 | * reply to in case of questions or problems. This configuration option |
||
285 | * overwrites the name set via "client/html/email/reply-name". |
||
286 | * |
||
287 | * @param string Name shown in the e-mail |
||
288 | * @since 2014.03 |
||
289 | * @category User |
||
290 | * @see client/html/email/delivery/reply-email |
||
291 | * @see client/html/email/reply-name |
||
292 | * @see client/html/email/reply-email |
||
293 | * @see client/html/email/from-email |
||
294 | * @see client/html/email/bcc-email |
||
295 | */ |
||
296 | $replyNameDelivery = $config->get( 'client/html/email/delivery/reply-name', $replyName ); |
||
297 | |||
298 | /** client/html/email/reply-email |
||
299 | * E-Mail address used by the customer when replying to e-mails |
||
300 | * |
||
301 | * The e-mail address of the person or e-mail account the customer |
||
302 | * should reply to in case of questions or problems. |
||
303 | * |
||
304 | * @param string E-mail address |
||
305 | * @since 2014.03 |
||
306 | * @category User |
||
307 | * @see client/html/email/reply-name |
||
308 | * @see client/html/email/delivery/reply-email |
||
309 | * @see client/html/email/from-email |
||
310 | * @see client/html/email/bcc-email |
||
311 | */ |
||
312 | $replyEmail = $config->get( 'client/html/email/reply-email', $fromEmail ); |
||
313 | |||
314 | /** client/html/email/delivery/reply-email |
||
315 | * E-Mail address used by the customer when replying to delivery e-mails |
||
316 | * |
||
317 | * The e-mail address of the person or e-mail account the customer |
||
318 | * should reply to in case of questions or problems. This configuration |
||
319 | * option overwrites the e-mail address set via "client/html/email/reply-email". |
||
320 | * |
||
321 | * @param string E-mail address |
||
322 | * @since 2014.03 |
||
323 | * @category User |
||
324 | * @see client/html/email/delivery/reply-name |
||
325 | * @see client/html/email/reply-email |
||
326 | * @see client/html/email/from-email |
||
327 | * @see client/html/email/bcc-email |
||
328 | */ |
||
329 | if( ( $replyEmailDelivery = $config->get( 'client/html/email/delivery/reply-email', $replyEmail ) ) != null ) { |
||
330 | $msg->replyTo( $replyEmailDelivery, $replyNameDelivery ); |
||
331 | } |
||
332 | |||
333 | |||
334 | /** client/html/email/bcc-email |
||
335 | * E-Mail address all e-mails should be also sent to |
||
336 | * |
||
337 | * Using this option you can send a copy of all shop related e-mails to |
||
338 | * a second e-mail account. This can be handy for testing and checking |
||
339 | * the e-mails sent to customers. |
||
340 | * |
||
341 | * It also allows shop owners with a very small volume of orders to be |
||
342 | * notified about new orders. Be aware that this isn't useful if the |
||
343 | * order volumne is high or has peeks! |
||
344 | * |
||
345 | * @param string E-mail address |
||
346 | * @since 2014.03 |
||
347 | * @category User |
||
348 | * @category Developer |
||
349 | * @see client/html/email/delivery/bcc-email |
||
350 | * @see client/html/email/reply-email |
||
351 | * @see client/html/email/from-email |
||
352 | */ |
||
353 | $bccEmail = $config->get( 'client/html/email/bcc-email' ); |
||
354 | |||
355 | /** client/html/email/delivery/bcc-email |
||
356 | * E-Mail address all delivery e-mails should be also sent to |
||
357 | * |
||
358 | * Using this option you can send a copy of all delivery related e-mails |
||
359 | * to a second e-mail account. This can be handy for testing and checking |
||
360 | * the e-mails sent to customers. |
||
361 | * |
||
362 | * It also allows shop owners with a very small volume of orders to be |
||
363 | * notified about new orders. Be aware that this isn't useful if the |
||
364 | * order volumne is high or has peeks! |
||
365 | * |
||
366 | * This configuration option overwrites the e-mail address set via |
||
367 | * "client/html/email/bcc-email". |
||
368 | * |
||
369 | * @param string|array E-mail address or list of e-mail addresses |
||
370 | * @since 2014.03 |
||
371 | * @category User |
||
372 | * @category Developer |
||
373 | * @see client/html/email/bcc-email |
||
374 | * @see client/html/email/reply-email |
||
375 | * @see client/html/email/from-email |
||
376 | */ |
||
377 | if( ( $bccEmailDelivery = $config->get( 'client/html/email/delivery/bcc-email', $bccEmail ) ) != null ) |
||
378 | { |
||
379 | foreach( (array) $bccEmailDelivery as $emailAddr ) { |
||
380 | $msg->Bcc( $emailAddr ); |
||
381 | } |
||
382 | } |
||
383 | |||
384 | |||
385 | /** client/html/email/delivery/template-header |
||
386 | * Relative path to the text header template of the email delivery client. |
||
387 | * |
||
388 | * The template file contains the text and processing instructions |
||
389 | * to generate the text that is inserted into the header |
||
390 | * of the e-mail. The configuration string is the |
||
391 | * path to the template file relative to the templates directory (usually |
||
392 | * in client/html/templates). |
||
393 | * |
||
394 | * You can overwrite the template file configuration in extensions and |
||
395 | * provide alternative templates. These alternative templates should be |
||
396 | * named like the default one but with the string "standard" replaced by |
||
397 | * an unique name. You may use the name of your project for this. If |
||
398 | * you've implemented an alternative client class as well, "standard" |
||
399 | * should be replaced by the name of the new class. |
||
400 | * |
||
401 | * The email payment text client allows to use a different template for |
||
402 | * each payment status value. You can create a template for each payment |
||
403 | * status and store it in the "email/payment/<status number>/" directory |
||
404 | * below the "templates" directory (usually in client/html/templates). If no |
||
405 | * specific layout template is found, the common template in the |
||
406 | * "email/payment/" directory is used. |
||
407 | * |
||
408 | * @param string Relative path to the template creating code for the e-mail header |
||
409 | * @since 2014.03 |
||
410 | * @category Developer |
||
411 | * @see client/html/email/delivery/template-body |
||
412 | */ |
||
413 | $tplconf = 'client/html/email/delivery/template-header'; |
||
414 | |||
415 | $status = $view->extOrderItem->getStatusDelivery(); |
||
416 | $default = array( 'email/delivery/' . $status . '/header-standard', 'email/delivery/header-standard' ); |
||
417 | |||
418 | return $view->render( $view->config( $tplconf, $default ) ); ; |
||
419 | } |
||
620 |