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

Mailer   A

Complexity

Total Complexity 7

Size/Duplication

Total Lines 117
Duplicated Lines 0 %

Test Coverage

Coverage 100%

Importance

Changes 0
Metric Value
eloc 46
dl 0
loc 117
ccs 43
cts 43
cp 1
rs 10
c 0
b 0
f 0
wmc 7

1 Method

Rating   Name   Duplication   Size   Complexity  
A sendMessage() 0 13 1
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