Conditions | 6 |
Paths | 32 |
Total Lines | 37 |
Code Lines | 19 |
Lines | 0 |
Ratio | 0 % |
Tests | 20 |
CRAP Score | 6 |
Changes | 0 |
1 | <?php |
||
22 | 3 | public function sendMessage( |
|
23 | string $to, |
||
24 | string $subject, |
||
25 | array $options, |
||
26 | array $params, |
||
27 | MailerInterface $mailer |
||
28 | ): bool { |
||
29 | 3 | if (isset(\Yii::$app->params['helper.mailer.viewpath'])) { |
|
30 | 3 | $mailer->viewPath = \Yii::$app->params['helper.mailer.viewpath']; |
|
|
|||
31 | } |
||
32 | |||
33 | 3 | $views = isset($options['views']) ? $options['views'] : []; |
|
34 | |||
35 | 3 | $this->emailConfig = $mailer |
|
36 | 3 | ->compose($views, $params) |
|
37 | 3 | ->setTo($to) |
|
38 | 3 | ->setFrom( |
|
39 | 3 | [\Yii::$app->params['helper.mailer.sender'] => \Yii::$app->params['helper.mailer.sender.name']] |
|
40 | ) |
||
41 | 3 | ->setSubject($subject); |
|
42 | |||
43 | 3 | if (isset($options['replyTo'])) { |
|
44 | 1 | $this->emailConfig = $this->emailConfig |
|
45 | 1 | ->setReplyTo($options['replyTo']); |
|
46 | } |
||
47 | |||
48 | 3 | if (isset($options['textBody'])) { |
|
49 | 2 | $this->emailConfig = $this->emailConfig |
|
50 | 2 | ->setTextBody($options['textBody']); |
|
51 | } |
||
52 | |||
53 | 3 | if (isset($options['textHtml'])) { |
|
54 | 1 | $this->emailConfig = $this->emailConfig |
|
55 | 1 | ->setHtmlBody($options['textHtml']); |
|
56 | } |
||
57 | |||
58 | 3 | return $mailer->send($this->emailConfig); |
|
59 | } |
||
61 |