SMSCServiceProvider::boot()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 25

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 1
nc 1
nop 0
dl 0
loc 25
rs 9.52
c 0
b 0
f 0
1
<?php
2
/**
3
 * Author: Facundo J Gonzalez
4
 * Date: 17/11/2017.
5
 */
6
7
namespace NotificationChannels\SMSC;
8
9
use GuzzleHttp\Client;
10
use Illuminate\Support\ServiceProvider;
11
use NotificationChannels\SMSC\Clients\Http\SMSCClient;
12
use NotificationChannels\SMSC\Clients\SMSCClientInterface;
13
14
/**
15
 * Class SMSCServiceProvider.
16
 */
17
class SMSCServiceProvider extends ServiceProvider
18
{
19
    /**
20
     * Bootstrap the application services.
21
     */
22
    public function boot()
23
    {
24
        $this->app->when(SMSCChannel::class)
25
                  ->needs(SMSCClientInterface::class)
26
                  ->give(function () {
27
                      $config = config('services.SMSC', [
28
                          'http'       => [
29
                              'endpoint' => 'https://www.smsc.com.ar/api/0.3/',
30
                          ],
31
                          'alias'   => '',
32
                          'apikey'   => '',
33
                          'timeout'    => '',
34
                      ]);
35
36
                      $endpoint = $config['http']['endpoint'];
37
                      $alias = $config['alias'];
38
                      $apikey = $config['apikey'];
39
                      $timeout = $config['timeout'];
40
41
                      $guzzleHttpClient = new Client(['timeout' => $timeout]);
42
                      $SMSCClient = new SMSCClient($guzzleHttpClient, $endpoint, $alias, $apikey);
43
44
                      return $SMSCClient;
45
                  });
46
    }
47
}
48