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