CmsmsServiceProvider::boot()   A
last analyzed

Complexity

Conditions 2
Paths 1

Size

Total Lines 10
Code Lines 6

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 0
CRAP Score 6

Importance

Changes 1
Bugs 0 Features 0
Metric Value
eloc 6
c 1
b 0
f 0
dl 0
loc 10
ccs 0
cts 8
cp 0
rs 10
cc 2
nc 1
nop 0
crap 6
1
<?php
2
3
declare(strict_types=1);
4
5
namespace NotificationChannels\Cmsms;
6
7
use GuzzleHttp\Client as GuzzleClient;
8
use Illuminate\Support\ServiceProvider;
9
use NotificationChannels\Cmsms\Exceptions\InvalidConfiguration;
10
11
class CmsmsServiceProvider extends ServiceProvider
12
{
13
    public function boot()
14
    {
15
        $this->app->when(CmsmsChannel::class)
16
            ->needs(CmsmsClient::class)
17
            ->give(function () {
18
                if (is_null($productToken = config('services.cmsms.product_token'))) {
19
                    throw InvalidConfiguration::configurationNotSet();
20
                }
21
22
                return new CmsmsClient(new GuzzleClient(), $productToken);
23
            });
24
    }
25
}
26