Completed
Pull Request — master (#21)
by
unknown
01:23
created

PostmarkServiceProvider::guzzle()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 4

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 0
CRAP Score 2

Importance

Changes 0
Metric Value
dl 0
loc 4
ccs 0
cts 2
cp 0
rs 10
c 0
b 0
f 0
cc 1
nc 1
nop 1
crap 2
1
<?php
2
3
namespace Coconuts\Mail;
4
5
use GuzzleHttp\Client as HttpClient;
6
use Illuminate\Support\ServiceProvider;
7
8
class PostmarkServiceProvider extends ServiceProvider
9
{
10
    /**
11
     * Boot the service provider.
12
     *
13
     * @return void
14
     */
15
    public function boot()
16
    {
17
        $this->publishes([
18
            __DIR__ . '/../config/postmark.php' => config_path('postmark.php')
19
        ], 'config');
20
21
        if ($this->app['config']['mail.driver'] != 'postmark') {
22
            return;
23
        }
24
25
        $this->mergeConfigFrom(__DIR__ . '/../config/postmark.php', 'postmark');
26
27
        $this->app['swift.transport']->extend('postmark', function () {
28
            return new PostmarkTransport(
29
                $this->guzzle(config('postmark.guzzle', [])),
30
                config('postmark.secret', config('services.postmark.secret'))
31
            );
32
        });
33
    }
34
35
    /**
36
     * Get a fresh Guzzle HTTP client instance.
37
     *
38
     * @param array $config
39
     *
40
     * @return \GuzzleHttp\Client
41
     */
42
    protected function guzzle($config)
43
    {
44
        return new HttpClient($config);
45
    }
46
}
47