Completed
Push — dev ( 65110e...7fe0a7 )
by Shingo
02:11
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 SendGridTransport|SendgridV3Transport
15
     */
16
    protected function createSendgridDriver()
17
    {
18
        $config = $this->app['config']->get('services.sendgrid', array());
19
        $client = new HttpClient(Arr::get($config, 'guzzle', []));
20
        if (Arr::get($config, 'version') === 'v3') {
21
            $pretend = isset($config['pretend']) ? $config['pretend'] : false;
22
            return new SendgridV3Transport($client, $config['api_key'], $pretend);
23
        }
24
        return new SendgridTransport($client, $config['api_key']);
25
    }
26
}
27