IntercomServiceProvider   A
last analyzed

Complexity

Total Complexity 2

Size/Duplication

Total Lines 28
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 6

Test Coverage

Coverage 100%

Importance

Changes 0
Metric Value
wmc 2
lcom 1
cbo 6
dl 0
loc 28
c 0
b 0
f 0
ccs 12
cts 12
cp 1
rs 10

2 Methods

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