Completed
Push — dev ( ca8f8d...65110e )
by Shingo
02:43
created

TransportManager::createSendgridV3Driver()   A

Complexity

Conditions 2
Paths 2

Size

Total Lines 7
Code Lines 5

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
c 1
b 0
f 0
dl 0
loc 7
rs 9.4285
cc 2
eloc 5
nc 2
nop 0
1
<?php
2
namespace Sichikawa\LaravelSendgridDriver;
3
4
use GuzzleHttp\Client as HttpClient;
5
use Illuminate\Support\Arr;
6
use Sichikawa\LaravelSendgridDriver\Transport\SendgridTransport;
7
use Sichikawa\LaravelSendgridDriver\Transport\SendgridV3Transport;
8
9
class TransportManager extends \Illuminate\Mail\TransportManager
10
{
11
    /**
12
     * Create an instance of the SendGrid Swift Transport driver.
13
     *
14
     * @return Transport\SendGridTransport
15
     */
16
    protected function createSendgridDriver()
17
    {
18
        $config = $this->app['config']->get('services.sendgrid', array());
19
        $client = new HttpClient(Arr::get($config, 'guzzle', []));
20
        return new SendgridTransport($client, $config['api_key']);
21
    }
22
23
    /**
24
     * Create an instance of the SendGrid Swift Transport driver.
25
     *
26
     * @return Transport\SendgridV3Transport
27
     */
28
    protected function createSendgridV3Driver()
29
    {
30
        $config = $this->app['config']->get('services.sendgrid', []);
31
        $client = new HttpClient(Arr::get($config, 'guzzle', []));
32
        $pretend = isset($config['pretend']) ? $config['pretend'] : false;
33
        return new SendgridV3Transport($client, $config['api_key'], $pretend);
34
    }
35
}
36