Completed
Push — dev ( 8ed28f...ffc33f )
by Shingo
08:34
created

SendGrid::addAttachments()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 5
Code Lines 3

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 5
rs 9.4285
c 0
b 0
f 0
cc 1
eloc 3
nc 1
nop 1
1
<?php
2
namespace Sichikawa\LaravelSendgridDriver;
3
4
use Illuminate\Mail\Mailable;
5
use Sichikawa\SendgridApiBuilder\SendGridApi;
6
use Swift_Message;
7
8
trait SendGrid
9
{
10
    use SendGridApi;
11
12
    /**
13
     * @param null|array $params
14
     * @return $this
15
     */
16
    public function sendgrid($params = null)
17
    {
18
        $this->sg_params = $params ?: $this->sg_params;
19
        if ($this instanceof Mailable) {
20
            $this->withSwiftMessage(function (Swift_Message $message) {
21
                $message->embed(\Swift_Image::newInstance($this->sg_params, 'sendgrid/x-smtpapi'));
22
            });
23
        }
24
        return $this;
25
    }
26
}
27