changed type hints
This commit is contained in:
parent
f6a6fb6834
commit
d56ae06ca3
@ -11,12 +11,10 @@
|
|||||||
|
|
||||||
namespace Symfony\Component\Mailer;
|
namespace Symfony\Component\Mailer;
|
||||||
|
|
||||||
use Symfony\Component\Mailer\Exception\InvalidArgumentException;
|
|
||||||
use Symfony\Component\Mailer\Exception\LogicException;
|
use Symfony\Component\Mailer\Exception\LogicException;
|
||||||
use Symfony\Component\Mime\Address;
|
use Symfony\Component\Mime\Address;
|
||||||
use Symfony\Component\Mime\Header\Headers;
|
use Symfony\Component\Mime\Header\Headers;
|
||||||
use Symfony\Component\Mime\Message;
|
use Symfony\Component\Mime\Message;
|
||||||
use Symfony\Component\Mime\RawMessage;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @author Fabien Potencier <fabien@symfony.com>
|
* @author Fabien Potencier <fabien@symfony.com>
|
||||||
@ -31,13 +29,8 @@ final class DelayedSmtpEnvelope extends SmtpEnvelope
|
|||||||
private $recipientsSet = false;
|
private $recipientsSet = false;
|
||||||
private $message;
|
private $message;
|
||||||
|
|
||||||
public function __construct(RawMessage $message)
|
public function __construct(Message $message)
|
||||||
{
|
{
|
||||||
if (!$message instanceof Message) {
|
|
||||||
// FIXME: parse the raw message to create the envelope?
|
|
||||||
throw new InvalidArgumentException(sprintf('Unable to create an SmtpEnvelope from a "%s" message.', RawMessage::class));
|
|
||||||
}
|
|
||||||
|
|
||||||
$this->message = $message;
|
$this->message = $message;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -91,10 +91,4 @@ class SmtpEnvelopeTest extends TestCase
|
|||||||
$e = SmtpEnvelope::create(new Message($headers));
|
$e = SmtpEnvelope::create(new Message($headers));
|
||||||
$this->assertEquals([new Address('to@symfony.com'), new Address('cc@symfony.com'), new Address('bcc@symfony.com')], $e->getRecipients());
|
$this->assertEquals([new Address('to@symfony.com'), new Address('cc@symfony.com'), new Address('bcc@symfony.com')], $e->getRecipients());
|
||||||
}
|
}
|
||||||
|
|
||||||
public function testCreateWithRawMessage()
|
|
||||||
{
|
|
||||||
$this->expectException(\InvalidArgumentException::class);
|
|
||||||
SmtpEnvelope::create(new RawMessage(''));
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
@ -28,17 +28,12 @@ final class MessageConverter
|
|||||||
/**
|
/**
|
||||||
* @throws RuntimeException when unable to convert the message to an email
|
* @throws RuntimeException when unable to convert the message to an email
|
||||||
*/
|
*/
|
||||||
public static function toEmail(RawMessage $message): Email
|
public static function toEmail(Message $message): Email
|
||||||
{
|
{
|
||||||
if ($message instanceof Email) {
|
if ($message instanceof Email) {
|
||||||
return $message;
|
return $message;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (RawMessage::class === \get_class($message)) {
|
|
||||||
// FIXME: parse the raw message to create the envelope?
|
|
||||||
throw new RuntimeException(sprintf('Unable to create an Email from an instance of "%s" as it is not supported yet.', RawMessage::class));
|
|
||||||
}
|
|
||||||
|
|
||||||
// try to convert to a "simple" Email instance
|
// try to convert to a "simple" Email instance
|
||||||
$body = $message->getBody();
|
$body = $message->getBody();
|
||||||
if ($body instanceof TextPart) {
|
if ($body instanceof TextPart) {
|
||||||
|
Reference in New Issue
Block a user