DispatcherServiceProvider   A
last analyzed

Complexity

Total Complexity 4

Size/Duplication

Total Lines 37
Duplicated Lines 0 %

Test Coverage

Coverage 0%

Importance

Changes 3
Bugs 0 Features 0
Metric Value
eloc 10
c 3
b 0
f 0
dl 0
loc 37
ccs 0
cts 12
cp 0
rs 10
wmc 4

4 Methods

Rating   Name   Duplication   Size   Complexity  
A provides() 0 5 1
A registerDispatcher() 0 5 1
A newDispatcher() 0 3 1
A register() 0 3 1
1
<?php
2
declare(strict_types=1);
3
4
namespace Nip\Dispatcher;
5
6
use Nip\Container\ServiceProviders\Providers\AbstractSignatureServiceProvider;
7
8
/**
9
 * Class MailServiceProvider.
10
 */
11
class DispatcherServiceProvider extends AbstractSignatureServiceProvider
12
{
13
    public const SERVICE_DISPATCHER = 'dispatcher';
14
15
    /**
16
     * {@inheritdoc}
17
     */
18
    public function provides()
19
    {
20
        return [
21
            static::SERVICE_DISPATCHER,
22
            Dispatcher::class
23
        ];
24
    }
25
26
    /**
27
     * {@inheritdoc}
28
     */
29
    public function register()
30
    {
31
        $this->registerDispatcher();
32
    }
33
34
    protected function registerDispatcher()
35
    {
36
        $this->getContainer()->alias('dispatcher', Dispatcher::class);
37
        $this->getContainer()->share('dispatcher', function () {
38
            return self::newDispatcher();
39
        });
40
    }
41
42
    /**
43
     * @return Dispatcher
44
     */
45
    public static function newDispatcher()
46
    {
47
        return new Dispatcher();
48
    }
49
}
50