IntercomServiceProvider::boot()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 12

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 8
CRAP Score 1

Importance

Changes 0
Metric Value
dl 0
loc 12
c 0
b 0
f 0
ccs 8
cts 8
cp 1
rs 9.8666
cc 1
nc 1
nop 0
crap 1
1
<?php
2
3
namespace NotificationChannels\Intercom;
4
5
use Illuminate\Container\Container;
6
use Illuminate\Support\Facades\Config;
7
use Illuminate\Support\Facades\Notification;
8
use Illuminate\Support\ServiceProvider;
9
use Intercom\IntercomClient;
10
11
class IntercomServiceProvider extends ServiceProvider
12
{
13
    /**
14
     * Bootstrap the application services.
15
     */
16 1
    public function boot(): void
17
    {
18 1
        $this->app->when(IntercomChannel::class)
19 1
            ->needs(IntercomClient::class)
20
            ->give(static function () {
21
                /* @var Config $config */
22 1
                return new IntercomClient(
23 1
                    Config::get('services.intercom.token', ''),
24 1
                    null
25
                );
26 1
            });
27 1
    }
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