Completed
Push — master ( 861879...e69be6 )
by Wilmer
01:42
created

Mailer::sendReconfirmationMessage()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 8
Code Lines 5

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 6
CRAP Score 1

Importance

Changes 0
Metric Value
cc 1
eloc 5
nc 1
nop 2
dl 0
loc 8
ccs 6
cts 6
cp 1
crap 1
rs 10
c 0
b 0
f 0
1
<?php
2
3
namespace terabytesoft\helpers;
4
5
use yii\base\Component;
6
use yii\db\ActiveRecord;
7
8
/**
9
 * Class Mailer
10
 *
11
 **/
12
class Mailer extends Component
13
{
14
    /**
15
     * sendMessage
16
     **/
17 1
    public function sendMessage(string $to, string $subject, string $view, array $params = []): bool
18
    {
19 1
        $mailer = \Yii::$app->mailer;
20
21 1
        $mailer->viewPath = \Yii::$app->params['helper.mailer.viewpath'];
0 ignored issues
show
Bug introduced by
Accessing viewPath on the interface yii\mail\MailerInterface suggest that you code against a concrete implementation. How about adding an instanceof check?
Loading history...
22
23 1
        return $mailer->compose(['html' => $view, 'text' => 'text/' . $view], $params)
24 1
            ->setTo($to)
25 1
            ->setFrom(
26 1
                [\Yii::$app->params['helper.mailer.sender'] => \Yii::$app->params['helper.mailer.sender.name']]
27
            )
28 1
            ->setSubject($subject)
29 1
            ->send();
30
    }
31
}
32