| Total Complexity | 3 |
| Total Lines | 45 |
| Duplicated Lines | 0 % |
| Changes | 1 | ||
| Bugs | 0 | Features | 0 |
| 1 | <?php |
||
| 19 | class EmailService implements EmailServiceInterface |
||
| 20 | { |
||
| 21 | /** |
||
| 22 | * @var Swift_Mailer |
||
| 23 | */ |
||
| 24 | private $mailer; |
||
| 25 | |||
| 26 | /** |
||
| 27 | * @var string |
||
| 28 | */ |
||
| 29 | private $replyEmail; |
||
| 30 | |||
| 31 | /** |
||
| 32 | * EmailService constructor. |
||
| 33 | */ |
||
| 34 | public function __construct(Swift_Mailer $mailer, ParameterBagInterface $parameterBag) |
||
| 35 | { |
||
| 36 | $this->mailer = $mailer; |
||
| 37 | $this->replyEmail = $parameterBag->get('REPLY_EMAIL'); |
||
| 38 | } |
||
| 39 | |||
| 40 | /** |
||
| 41 | * @param string[] $options |
||
| 42 | * |
||
| 43 | * @return bool |
||
| 44 | */ |
||
| 45 | public function sendEmail(string $receiver, string $subject, string $body) |
||
| 46 | { |
||
| 47 | $message = (new Swift_Message()) |
||
| 48 | ->setSubject($subject) |
||
| 49 | ->setFrom($this->replyEmail) |
||
| 50 | ->setReplyTo($this->replyEmail) |
||
| 51 | ->setTo($receiver) |
||
| 52 | ->setBody($body); |
||
| 53 | |||
| 54 | //send message & check if at least one receiver was reached |
||
| 55 | return $this->mailer->send($message) > 0; |
||
| 56 | } |
||
| 57 | |||
| 58 | /** |
||
| 59 | * @return bool |
||
| 60 | */ |
||
| 61 | public function sendEmailToAdministrator(string $subject, string $body) |
||
| 64 | } |
||
| 65 | } |
||
| 66 |