AfricasTalkingServiceProvider   A
last analyzed

Complexity

Total Complexity 3

Size/Duplication

Total Lines 24
Duplicated Lines 0 %

Test Coverage

Coverage 0%

Importance

Changes 1
Bugs 0 Features 0
Metric Value
eloc 12
c 1
b 0
f 0
dl 0
loc 24
ccs 0
cts 14
cp 0
rs 10
wmc 3

1 Method

Rating   Name   Duplication   Size   Complexity  
A boot() 0 19 3
1
<?php
2
3
namespace NotificationChannels\AfricasTalking;
4
5
use AfricasTalking\SDK\AfricasTalking as AfricasTalkingSDK;
6
use Illuminate\Support\ServiceProvider;
7
use NotificationChannels\AfricasTalking\Exceptions\InvalidConfiguration;
8
9
class AfricasTalkingServiceProvider extends ServiceProvider
10
{
11
    /**
12
     * Bootstrap the application services.
13
     */
14
    public function boot()
15
    {
16
        /**
17
         * Bootstrap the application services.
18
         */
19
        $this->app->when(AfricasTalkingChannel::class)
20
            ->needs(AfricasTalkingSDK::class)
21
            ->give(function () {
22
                $userName = config('services.africastalking.username');
23
                $key = config('services.africastalking.key');
24
                if (is_null($userName) || is_null($key)) {
25
                    throw InvalidConfiguration::configurationNotSet();
26
                }
27
                $at = new AfricasTalkingSDK(
28
                    $userName,
29
                    $key
30
                );
31
32
                return $at;
33
            });
34
    }
35
}
36