Issues (4)

src/Mapper/MailerMapper.php (3 issues)

Labels
Severity
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
It seems like $email->getSubject() can also be of type null; however, parameter $subject of ProjetNormandie\EmailBun...ity\Email::setSubject() 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 ignore-type  annotation

19
            ->setSubject(/** @scrutinizer ignore-type */ $email->getSubject())
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 ignore-type  annotation

21
            ->setBodyText(/** @scrutinizer ignore-type */ $email->getTextBody())
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 ignore-type  annotation

22
            ->setBodyHtml(/** @scrutinizer ignore-type */ $email->getHtmlBody());
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