Passed
Push — master ( 1877a1...37d1bb )
by Gabriel
10:54
created

NotificationServiceProvider   A

Complexity

Total Complexity 4

Size/Duplication

Total Lines 30
Duplicated Lines 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
eloc 8
c 1
b 0
f 0
dl 0
loc 30
rs 10
wmc 4

4 Methods

Rating   Name   Duplication   Size   Complexity  
A register() 0 4 1
A registerDispatcher() 0 4 1
A registerChannels() 0 4 1
A provides() 0 3 1
1
<?php
2
3
namespace ByTIC\Notifications;
4
5
use ByTIC\Notifications\Channels\ChannelInterface;
6
use ByTIC\Notifications\Dispatcher\Dispatcher;
7
use ByTIC\Notifications\Dispatcher\DispatcherInterface;
8
use Nip\Container\ServiceProviders\Providers\AbstractServiceProvider;
9
10
/**
11
 * Class NotificationServiceProvider
12
 * @package ByTIC\Notifications
13
 */
14
class NotificationServiceProvider extends AbstractServiceProvider
15
{
16
17
    /**
18
     * @inheritdoc
19
     */
20
    public function register()
21
    {
22
        $this->registerChannels();
23
        $this->registerDispatcher();
24
    }
25
26
    protected function registerChannels()
27
    {
28
        $manager = new ChannelManager();
29
        $this->getContainer()->share(ChannelInterface::class, $manager);
30
    }
31
32
    protected function registerDispatcher()
33
    {
34
        $dispatcher = new Dispatcher(app(ChannelInterface::class));
35
        $this->getContainer()->share(DispatcherInterface::class, $dispatcher);
36
    }
37
38
    /**
39
     * @inheritdoc
40
     */
41
    public function provides()
42
    {
43
        return [ChannelInterface::class, DispatcherInterface::class];
44
    }
45
}
46