WhatsappNotifyServiceProvider   A
last analyzed

Complexity

Total Complexity 3

Size/Duplication

Total Lines 37
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 6

Importance

Changes 0
Metric Value
wmc 3
lcom 1
cbo 6
dl 0
loc 37
rs 10
c 0
b 0
f 0

2 Methods

Rating   Name   Duplication   Size   Complexity  
A boot() 0 10 2
A register() 0 17 1
1
<?php
2
3
namespace Artisanpay\WhatsappNotify;
4
5
use Illuminate\Notifications\ChannelManager;
6
use Illuminate\Support\Facades\Notification;
7
use Illuminate\Support\ServiceProvider;
8
9
class WhatsappNotifyServiceProvider extends ServiceProvider
10
{
11
    /**
12
     * Bootstrap the application services.
13
     */
14
    public function boot()
15
    {
16
17
        if ($this->app->runningInConsole()) {
18
            $this->publishes([
19
                __DIR__.'/../config/config.php' => config_path('whatsapp.php'),
20
            ], 'config');
21
22
        }
23
    }
24
25
    /**
26
     * Register the application services.
27
     */
28
    public function register()
29
    {
30
        // Automatically apply the package configuration
31
        $this->mergeConfigFrom(__DIR__.'/../config/config.php', 'whatsapp');
32
33
        // Register the main class to use with the facade
34
        $this->app->singleton(WhatsappNotify::class, function () {
35
            return new WhatsappNotify;
36
        });
37
38
        Notification::resolved(function (ChannelManager $service) {
39
            $service->extend('whatsapp', function () {
40
                return new WhatsappChannel();
41
            });
42
        });
43
44
    }
45
}
46