Passed
Branch master (f22fa7)
by Stan
04:08
created

NotifierServiceProvider::boot()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 3
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
cc 1
eloc 1
c 1
b 0
f 0
nc 1
nop 0
dl 0
loc 3
rs 10
1
<?php
2
3
namespace Skater4\LaravelSentryNotifications\Providers;
4
5
use Illuminate\Support\ServiceProvider;
6
use Skater4\LaravelSentryNotifications\Notifications\Factories\NotificationEntityFactory;
7
use Skater4\LaravelSentryNotifications\Notifications\Factories\NotificationFactory;
8
use Skater4\LaravelSentryNotifications\Services\Factories\MessengerServiceFactory;
9
use Skater4\LaravelSentryNotifications\Services\Messengers\Factories\MessageFormatterFactory;
10
use Skater4\LaravelSentryNotifications\Services\Sentry\Interfaces\SentryServiceInterface;
11
use Skater4\LaravelSentryNotifications\Services\SentryNotifier;
12
13
class NotifierServiceProvider extends ServiceProvider
14
{
15
    /**
16
     * @return void
17
     */
18
    public function register(): void
19
    {
20
        $this->mergeConfigFrom(
21
            __DIR__ . '/../../config/services.php', 'services'
22
        );
23
24
        $this->app->singleton(SentryNotifier::class, function ($app) {
25
            return new SentryNotifier(
26
                MessengerServiceFactory::create($app['config']['services']['laravel-sentry-notifications']['service']),
27
                resolve(SentryServiceInterface::class),
28
            );
29
        });
30
31
        $this->app->singleton(MessageFormatterFactory::class, function ($app) {
32
            return new MessageFormatterFactory(
33
                $app['config']['services']['laravel-sentry-notifications']['service']
34
            );
35
        });
36
37
        $this->app->singleton(NotificationEntityFactory::class, function ($app) {
38
            return new NotificationEntityFactory(
39
                $app['config']['services']['laravel-sentry-notifications']['service']
40
            );
41
        });
42
43
        $this->app->singleton(NotificationFactory::class, function ($app) {
44
            return new NotificationFactory(
45
                $app['config']['services']['laravel-sentry-notifications']['service']
46
            );
47
        });
48
    }
49
}
50