SipgateServiceProvider   A
last analyzed

Complexity

Total Complexity 1

Size/Duplication

Total Lines 35
Duplicated Lines 0 %

Test Coverage

Coverage 0%

Importance

Changes 1
Bugs 0 Features 1
Metric Value
eloc 22
c 1
b 0
f 1
dl 0
loc 35
ccs 0
cts 23
cp 0
rs 10
wmc 1

1 Method

Rating   Name   Duplication   Size   Complexity  
A boot() 0 30 1
1
<?php
2
3
namespace NotificationChannels\Sipgate;
4
5
use GuzzleHttp\Client;
6
use Illuminate\Contracts\Foundation\Application;
7
use Illuminate\Notifications\ChannelManager;
8
use Illuminate\Support\ServiceProvider;
9
10
class SipgateServiceProvider extends ServiceProvider
11
{
12
    /**
13
     * Bootstrap the application services.
14
     */
15
    public function boot()
16
    {
17
        $this->app->afterResolving(ChannelManager::class, function (ChannelManager $channels) {
18
            $channels->extend('sipgate', function ($app) {
19
                /* @var Application $app */
20
                return $app->make(SipgateChannel::class);
21
            });
22
        });
23
24
        $this->app->when(SipgateChannel::class)
25
            ->needs('$smsId')
26
            ->give($this->app['config']['services.sipgate.smsId']);
27
28
        $this->app->when(SipgateChannel::class)
29
            ->needs('$channelEnabled')
30
            ->give($this->app['config']['services.sipgate.enabled']);
31
32
        $this->app->bind(SipgateClient::class, function () {
33
            return new SipgateClient(
34
                new Client([
35
                    'base_uri' => 'https://api.sipgate.com/v2/',
36
                    'auth' => [
37
                        $this->app['config']['services.sipgate.username'],
38
                        $this->app['config']['services.sipgate.password'],
39
                    ],
40
                    'headers' => [
41
                        'Accept' => 'application/json',
42
                        'Content-Type' => 'application/json',
43
                        'X-Sipgate-Client' => 'github.com/laravel-notification-channels/sipgate',
44
                        'X-Sipgate-Version' => '1.3.0',
45
                    ],
46
                ])
47
            );
48
        });
49
    }
50
}
51