8000 [Mailer] made code more robust · symfony/symfony@b12dcb2 · GitHub
[go: up one dir, main page]

Skip to content

Commit b12dcb2

Browse files
committed
[Mailer] made code more robust
1 parent ac1a660 commit b12dcb2

File tree

1 file changed

+6
-5
lines changed

1 file changed

+6
-5
lines changed

src/Symfony/Component/Mailer/SmtpEnvelope.php

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -42,14 +42,17 @@ public static function create(RawMessage $message): self
4242

4343
public function setSender(Address $sender): void
4444
{
45-
$this->sender = $sender instanceof NamedAddress ? new Address($sender->getAddress()) : $sender;
45+
$this->sender = new Address($sender->getAddress());
4646
}
4747

4848
public function getSender(): Address
4949
{
5050
return $this->sender;
5151
}
5252

53+
/**
54+
* @param Address[] $recipients
55+
*/
5356
public function setRecipients(array $recipients): void
5457
{
5558
if (!$recipients) {
@@ -58,12 +61,10 @@ public function setRecipients(array $recipients): void
5861

5962
$this->recipients = [];
6063
foreach ($recipients as $recipient) {
61-
if ($recipient instanceof NamedAddress) {
62-
$recipient = new Address($recipient->getAddress());
63-
} elseif (!$recipient instanceof Address) {
64+
if (!$recipient instanceof Address) {
6465
throw new InvalidArgumentException(sprintf('A recipient must be an instance of "%s" (got "%s").', Address::class, \is_object($recipient) ? \get_class($recipient) : \gettype($recipient)));
6566
}
66-
$this->recipients[] = $recipient;
67+
$this->recipients[] = new Address($recipient->getAddress());
6768
}
6869
}
6970

0 commit comments

Comments
 (0)
0