IntercomServiceProvider::boot()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 9
Code Lines 6

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 6
CRAP Score 1

Importance

Changes 1
Bugs 0 Features 0
Metric Value
cc 1
eloc 6
nc 1
nop 0
dl 0
loc 9
ccs 6
cts 6
cp 1
crap 1
rs 10
c 1
b 0
f 0
1
<?php
2
3
namespace FtwSoft\NotificationChannels\Intercom;
4
5
use Intercom\IntercomClient;
6
use Illuminate\Container\Container;
7
use Illuminate\Support\Facades\Config;
8
use Illuminate\Support\ServiceProvider;
9
use Illuminate\Support\Facades\Notification;
10
11
class IntercomServiceProvider extends ServiceProvider
12
{
13
    /**
14
     * Bootstrap the application services.
15
     */
16 2
    public function boot(): void
17
    {
18 2
        $this->app->when(IntercomChannel::class)
19 2
            ->needs(IntercomClient::class)
20
            ->give(static function () {
21
                /* @var Config $config */
22 2
                return new IntercomClient(
23 2
                    Config::get('services.intercom.token'),
24 2
                    null
25
                );
26 2
            });
27 2
    }
28
29
    /**
30
     * Register any package services.
31
     */
32 1
    public function register(): void
33
    {
34
        Notification::extend('intercom', static function (Container $app) {
35 1
            return $app->make(IntercomChannel::class);
36 1
        });
37 1
    }
38
}
39