@@ -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(), |