Completed
Push — master ( a03352...71a9a8 )
by Shingo
07:00
created

SendGrid::sendgrid()   A

Complexity

Conditions 2
Paths 2

Size

Total Lines 9
Code Lines 5

Duplication

Lines 0
Ratio 0 %

Importance

Changes 2
Bugs 0 Features 1
Metric Value
c 2
b 0
f 1
dl 0
loc 9
rs 9.6666
cc 2
eloc 5
nc 2
nop 1
1
<?php
2
namespace Sichikawa\LaravelSendgridDriver;
3
4
use Illuminate\Mail\Mailable;
5
use Swift_Message;
6
7
trait SendGrid
8
{
9
10
    /**
11
     * @param null|array $params
12
     * @return $this
13
     */
14
    public function sendgrid($params)
15
    {
16
        if ($this instanceof Mailable) {
17
            $this->withSwiftMessage(function (Swift_Message $message) use ($params) {
18
                $message->embed(\Swift_Image::newInstance($params, 'sendgrid/x-smtpapi'));
0 ignored issues
show
Bug introduced by
It seems like $params defined by parameter $params on line 14 can also be of type array; however, Swift_Image::newInstance() does only seem to accept string|object<Swift_OutputByteStream>|null, maybe add an additional type check?

This check looks at variables that have been passed in as parameters and are passed out again to other methods.

If the outgoing method call has stricter type requirements than the method itself, an issue is raised.

An additional type check may prevent trouble.

Loading history...
19
            });
20
        }
21
        return $this;
22
    }
23
}
24