/**
  * @param $message
  * @param string $destination
  * @param null $transport
  * @return MailgunMessage|\PHPMailer|\Swift_Message|Message
  * @throws MailWrapperSetupException
  */
 public static function convert($message, $destination = 'wrappedMessage', $transport = null)
 {
     switch (true) {
         case $message instanceof MailWrappedMessage:
             break;
         case $message instanceof Message:
             $message = MessageTransformerZend::toWrappedMessage($message);
             break;
         case $message instanceof MessageBuilder:
             $message = MessageTransformerMailgun::toWrappedMessage($message);
             break;
         case $message instanceof \PHPMailer:
             $message = MessageTransformerPhpMailer::toWrappedMessage($message);
             break;
         case $message instanceof \Swift_Message:
             $message = MessageTransformerSwift::toWrappedMessage($message);
             break;
         default:
             throw new MailWrapperSetupException('No Message Converter');
     }
     switch ($destination) {
         case 'mailgun':
             return MessageTransformerMailgun::fromWrappedMessage($message, $transport);
         case 'phpmailer':
             return MessageTransformerPhpMailer::fromWrappedMessage($message);
         case 'swift':
             return MessageTransformerSwift::fromWrappedMessage($message);
         case 'zend':
             return MessageTransformerZend::fromWrappedMessage($message);
         case 'wrappedMessage':
             return $message;
         default:
             throw new MailWrapperSetupException('No Message Converter');
     }
 }
Пример #2
0
 /**
  * @expectedException \BespokeSupport\MailWrapper\MailWrapperSetupException
  */
 public function testNullFromWrappedMessage()
 {
     MessageTransformerPhpMailer::fromWrappedMessage(null);
 }