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

TransportManager   A

Complexity

Total Complexity 3

Size/Duplication

Total Lines 27
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 5

Importance

Changes 2
Bugs 0 Features 0
Metric Value
wmc 3
c 2
b 0
f 0
lcom 1
cbo 5
dl 0
loc 27
rs 10

2 Methods

Rating   Name   Duplication   Size   Complexity  
A createSendgridDriver() 0 6 1
A createSendgridV3Driver() 0 7 2
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