Completed
Push — master ( 1cfd7b...f34219 )
by Yaro
9s
created

Mail::send()   A

Complexity

Conditions 2
Paths 2

Size

Total Lines 11
Code Lines 6

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 11
rs 9.4285
c 0
b 0
f 0
cc 2
eloc 6
nc 2
nop 0
1
<?php 
2
3
namespace Yaro\LogEnvelope\Drivers;
4
5
use Illuminate\Support\Facades\Mail as MailFacade;
6
use Yaro\LogEnvelope\Mail\LogEmail;
7
8
class Mail extends AbstractDriver
9
{
10
    
11
    protected function prepare() 
12
    {
13
        $this->config['from_name']  = $this->config['from_name'] ?: 'Log Envelope';
14
        $this->config['from_email'] = $this->config['from_email'] ?: 'logenvelope@'. $this->data['host'];
15
    } // end prepare
16
    
17
    protected function check() 
18
    {
19
        return $this->isEnabled() && (isset($this->config['to']) && $this->config['to']);
20
    } // end check
21
    
22
    public function send()
23
    {
24
        if (!$this->check()) {
25
            return;
26
        }
27
        
28
        $data = $this->data;
29
        $config = $this->config;
30
        
31
        MailFacade::queue(new LogEmail($data, $config));
32
    } // end send
33
    
34
}
35