SMSCServiceProvider   A
last analyzed

Complexity

Total Complexity 1

Size/Duplication

Total Lines 31
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 5

Importance

Changes 0
Metric Value
wmc 1
lcom 1
cbo 5
dl 0
loc 31
rs 10
c 0
b 0
f 0

1 Method

Rating   Name   Duplication   Size   Complexity  
A boot() 0 25 1
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