projet-normandie /
email-bundle
| 1 | <?php |
||||
| 2 | |||||
| 3 | namespace ProjetNormandie\EmailBundle\Mapper; |
||||
| 4 | |||||
| 5 | use ProjetNormandie\EmailBundle\Entity\Email as EmailEntity; |
||||
| 6 | use Symfony\Component\Mime\Email; |
||||
| 7 | |||||
| 8 | /** |
||||
| 9 | * Mapper class upon the Swift_Mailer to send Swift_Messages. |
||||
| 10 | */ |
||||
| 11 | class MailerMapper |
||||
| 12 | { |
||||
| 13 | /** |
||||
| 14 | * Transforms an Email message to an Email entity |
||||
| 15 | */ |
||||
| 16 | public function fromEmail(Email $email): EmailEntity |
||||
| 17 | { |
||||
| 18 | $emailEntity = (new EmailEntity()) |
||||
| 19 | ->setSubject($email->getSubject()) |
||||
|
0 ignored issues
–
show
Bug
introduced
by
Loading history...
|
|||||
| 20 | ->setTargetMail($email->getTo()[0]->toString()) |
||||
| 21 | ->setBodyText($email->getTextBody()) |
||||
|
0 ignored issues
–
show
It seems like
$email->getTextBody() can also be of type null and resource; however, parameter $bodyText of ProjetNormandie\EmailBun...ty\Email::setBodyText() does only seem to accept string, maybe add an additional type check?
(
Ignorable by Annotation
)
If this is a false-positive, you can also ignore this issue in your code via the
Loading history...
|
|||||
| 22 | ->setBodyHtml($email->getHtmlBody()); |
||||
|
0 ignored issues
–
show
It seems like
$email->getHtmlBody() can also be of type null and resource; however, parameter $bodyHtml of ProjetNormandie\EmailBun...ty\Email::setBodyHtml() does only seem to accept string, maybe add an additional type check?
(
Ignorable by Annotation
)
If this is a false-positive, you can also ignore this issue in your code via the
Loading history...
|
|||||
| 23 | |||||
| 24 | if (count($email->getFrom()) > 0) { |
||||
| 25 | $emailEntity->setFrom($email->getFrom()[0]->toString()); |
||||
| 26 | } |
||||
| 27 | |||||
| 28 | if (count($email->getReplyTo()) > 0) { |
||||
| 29 | $emailEntity->setFrom($email->getReplyTo()[0]->toString()); |
||||
| 30 | } |
||||
| 31 | |||||
| 32 | return $emailEntity; |
||||
| 33 | } |
||||
| 34 | } |
||||
| 35 |