WhatsappNotifyServiceProvider::boot()   A
last analyzed

Complexity

Conditions 2
Paths 2

Size

Total Lines 10

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 10
rs 9.9332
c 0
b 0
f 0
cc 2
nc 2
nop 0
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