Code Coverage |
||||||||||
Classes and Traits |
Functions and Methods |
Lines |
||||||||
| Total | |
0.00% |
0 / 1 |
|
0.00% |
0 / 7 |
CRAP | |
0.00% |
0 / 16 |
| MailSender | |
0.00% |
0 / 1 |
|
0.00% |
0 / 7 |
72 | |
0.00% |
0 / 16 |
| __construct | |
0.00% |
0 / 1 |
2 | |
0.00% |
0 / 2 |
|||
| get | |
0.00% |
0 / 1 |
6 | |
0.00% |
0 / 3 |
|||
| model | |
0.00% |
0 / 1 |
2 | |
0.00% |
0 / 3 |
|||
| to | |
0.00% |
0 / 1 |
2 | |
0.00% |
0 / 2 |
|||
| cc | |
0.00% |
0 / 1 |
2 | |
0.00% |
0 / 2 |
|||
| bcc | |
0.00% |
0 / 1 |
2 | |
0.00% |
0 / 2 |
|||
| dispatch | |
0.00% |
0 / 1 |
2 | |
0.00% |
0 / 2 |
|||
| 1 | <?php |
| 2 | |
| 3 | namespace Qmp\Laravel\Mail; |
| 4 | |
| 5 | use Illuminate\Mail\Mailable; |
| 6 | use Qmp\Laravel\Mail\Jobs\SendMail; |
| 7 | |
| 8 | class MailSender |
| 9 | { |
| 10 | private $type; |
| 11 | |
| 12 | private $to; |
| 13 | |
| 14 | private $cc; |
| 15 | |
| 16 | private $bcc; |
| 17 | |
| 18 | private $content; |
| 19 | |
| 20 | public function __construct() |
| 21 | { |
| 22 | $this->type = env('MAIL_SERVICE_DRIVER', 'smtp'); |
| 23 | } |
| 24 | |
| 25 | public function get($item) |
| 26 | { |
| 27 | if(isset($this->$item)) { |
| 28 | return $this->$item; |
| 29 | } |
| 30 | |
| 31 | return null; |
| 32 | } |
| 33 | |
| 34 | public static function model(Mailable $modelMail) |
| 35 | { |
| 36 | $email = new MailSender(); |
| 37 | $email->content = $modelMail; |
| 38 | |
| 39 | return $email; |
| 40 | } |
| 41 | |
| 42 | public function to(string $to) |
| 43 | { |
| 44 | $this->to = $to; |
| 45 | |
| 46 | return $this; |
| 47 | } |
| 48 | |
| 49 | public function cc(string $cc) |
| 50 | { |
| 51 | $this->cc = $cc; |
| 52 | |
| 53 | return $this; |
| 54 | } |
| 55 | |
| 56 | public function bcc(string $bcc) |
| 57 | { |
| 58 | $this->bcc = $bcc; |
| 59 | |
| 60 | return $this; |
| 61 | } |
| 62 | |
| 63 | public function dispatch() |
| 64 | { |
| 65 | SendMail::dispatch($this); |
| 66 | } |
| 67 | } |