Completed
Push — master ( 7ab1ca...c15062 )
by Simon
06:15 queued 05:12
created

SipgateServiceProvider::boot()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 24

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 0
CRAP Score 2

Importance

Changes 0
Metric Value
dl 0
loc 24
ccs 0
cts 20
cp 0
rs 9.536
c 0
b 0
f 0
cc 1
nc 1
nop 0
crap 2
1
<?php
2
3
namespace SimonKub\Laravel\Notifications\Sipgate;
4
5
use GuzzleHttp\Client;
6
use Illuminate\Support\ServiceProvider;
7
use Illuminate\Notifications\ChannelManager;
8
9
class SipgateServiceProvider extends ServiceProvider
10
{
11
    /**
12
     * Bootstrap the application services.
13
     */
14
    public function boot()
15
    {
16
        $this->app->afterResolving(ChannelManager::class, function (ChannelManager $channels) {
17
            $channels->extend('sipgate', function ($app) {
18
                return $app[SipgateChannel::class];
19
            });
20
        });
21
22
        $this->app->bind(SipgateClient::class, function () {
23
            return new SipgateClient(
24
                new Client([
25
                    'base_uri' => 'https://api.sipgate.com/v2/',
26
                    'auth' => [
27
                        $this->app['config']['services.sipgate.username'],
28
                        $this->app['config']['services.sipgate.password'],
29
                    ],
30
                    'headers' => [
31
                        'Accept' => 'application/json',
32
                        'Content-Type' => 'application/json',
33
                    ],
34
                ])
35
            );
36
        });
37
    }
38
39
    /**
40
     * Register the application services.
41
     */
42
    public function register()
43
    {
44
        //
45
    }
46
}
47