@@ -15,7 +15,7 @@ discard block |
||
| 15 | 15 | { |
| 16 | 16 | public function __construct( |
| 17 | 17 | private readonly ViewsInterface $views, |
| 18 | - ) {} |
|
| 18 | + ){} |
|
| 19 | 19 | |
| 20 | 20 | /** |
| 21 | 21 | * Copy-pasted form https://stackoverflow.com/a/20806227 |
@@ -26,7 +26,7 @@ discard block |
||
| 26 | 26 | */ |
| 27 | 27 | public static function escapeSubject(string $subject): string |
| 28 | 28 | { |
| 29 | - if (!\preg_match('/[^\x20-\x7e]/', $subject)) { |
|
| 29 | + if (!\preg_match('/[^\x20-\x7e]/', $subject)){ |
|
| 30 | 30 | // ascii-only subject, return as-is |
| 31 | 31 | return $subject; |
| 32 | 32 | } |
@@ -36,14 +36,14 @@ discard block |
||
| 36 | 36 | $prefix = '=?UTF-8?B?'; |
| 37 | 37 | $suffix = '?='; |
| 38 | 38 | |
| 39 | - return $prefix . \str_replace("=\r\n", $suffix . "\r\n " . $prefix, $encoded) . $suffix; |
|
| 39 | + return $prefix.\str_replace("=\r\n", $suffix."\r\n ".$prefix, $encoded).$suffix; |
|
| 40 | 40 | } |
| 41 | 41 | |
| 42 | 42 | public function render(MessageInterface $message): Email |
| 43 | 43 | { |
| 44 | - try { |
|
| 44 | + try{ |
|
| 45 | 45 | $view = $this->views->get($message->getSubject()); |
| 46 | - } catch (ViewException $e) { |
|
| 46 | + }catch (ViewException $e){ |
|
| 47 | 47 | throw new MailerException( |
| 48 | 48 | \sprintf('Invalid email template `%s`: %s', $message->getSubject(), $e->getMessage()), |
| 49 | 49 | $e->getCode(), |
@@ -53,11 +53,11 @@ discard block |
||
| 53 | 53 | |
| 54 | 54 | $msg = new Email(); |
| 55 | 55 | |
| 56 | - if ($message->getFrom() !== null) { |
|
| 56 | + if ($message->getFrom() !== null){ |
|
| 57 | 57 | $msg->from($message->getFrom()); |
| 58 | 58 | } |
| 59 | 59 | |
| 60 | - if ($message->getReplyTo() !== null) { |
|
| 60 | + if ($message->getReplyTo() !== null){ |
|
| 61 | 61 | $msg->replyTo($message->getReplyTo()); |
| 62 | 62 | } |
| 63 | 63 | |
@@ -65,10 +65,10 @@ discard block |
||
| 65 | 65 | $msg->cc(...$message->getCC()); |
| 66 | 66 | $msg->bcc(...$message->getBCC()); |
| 67 | 67 | |
| 68 | - try { |
|
| 68 | + try{ |
|
| 69 | 69 | // render message partials |
| 70 | 70 | $view->render(\array_merge(['_msg_' => $msg], $message->getData())); |
| 71 | - } catch (ViewException $e) { |
|
| 71 | + }catch (ViewException $e){ |
|
| 72 | 72 | throw new MailerException( |
| 73 | 73 | \sprintf('Unable to render email `%s`: %s', $message->getSubject(), $e->getMessage()), |
| 74 | 74 | $e->getCode(), |
@@ -15,7 +15,8 @@ discard block |
||
| 15 | 15 | { |
| 16 | 16 | public function __construct( |
| 17 | 17 | private readonly ViewsInterface $views, |
| 18 | - ) {} |
|
| 18 | + ) { |
|
| 19 | +} |
|
| 19 | 20 | |
| 20 | 21 | /** |
| 21 | 22 | * Copy-pasted form https://stackoverflow.com/a/20806227 |
@@ -26,7 +27,8 @@ discard block |
||
| 26 | 27 | */ |
| 27 | 28 | public static function escapeSubject(string $subject): string |
| 28 | 29 | { |
| 29 | - if (!\preg_match('/[^\x20-\x7e]/', $subject)) { |
|
| 30 | + if (!\preg_match('/[^\x20-\x7e]/', $subject)) |
|
| 31 | + { |
|
| 30 | 32 | // ascii-only subject, return as-is |
| 31 | 33 | return $subject; |
| 32 | 34 | } |
@@ -41,9 +43,12 @@ discard block |
||
| 41 | 43 | |
| 42 | 44 | public function render(MessageInterface $message): Email |
| 43 | 45 | { |
| 44 | - try { |
|
| 46 | + try |
|
| 47 | + { |
|
| 45 | 48 | $view = $this->views->get($message->getSubject()); |
| 46 | - } catch (ViewException $e) { |
|
| 49 | + } |
|
| 50 | + catch (ViewException $e) |
|
| 51 | + { |
|
| 47 | 52 | throw new MailerException( |
| 48 | 53 | \sprintf('Invalid email template `%s`: %s', $message->getSubject(), $e->getMessage()), |
| 49 | 54 | $e->getCode(), |
@@ -53,11 +58,13 @@ discard block |
||
| 53 | 58 | |
| 54 | 59 | $msg = new Email(); |
| 55 | 60 | |
| 56 | - if ($message->getFrom() !== null) { |
|
| 61 | + if ($message->getFrom() !== null) |
|
| 62 | + { |
|
| 57 | 63 | $msg->from($message->getFrom()); |
| 58 | 64 | } |
| 59 | 65 | |
| 60 | - if ($message->getReplyTo() !== null) { |
|
| 66 | + if ($message->getReplyTo() !== null) |
|
| 67 | + { |
|
| 61 | 68 | $msg->replyTo($message->getReplyTo()); |
| 62 | 69 | } |
| 63 | 70 | |
@@ -65,10 +72,13 @@ discard block |
||
| 65 | 72 | $msg->cc(...$message->getCC()); |
| 66 | 73 | $msg->bcc(...$message->getBCC()); |
| 67 | 74 | |
| 68 | - try { |
|
| 75 | + try |
|
| 76 | + { |
|
| 69 | 77 | // render message partials |
| 70 | 78 | $view->render(\array_merge(['_msg_' => $msg], $message->getData())); |
| 71 | - } catch (ViewException $e) { |
|
| 79 | + } |
|
| 80 | + catch (ViewException $e) |
|
| 81 | + { |
|
| 72 | 82 | throw new MailerException( |
| 73 | 83 | \sprintf('Unable to render email `%s`: %s', $message->getSubject(), $e->getMessage()), |
| 74 | 84 | $e->getCode(), |