DispatcherServiceProvider::newDispatcher()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 3
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 0
CRAP Score 2

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
ccs 0
cts 0
cp 0
crap 2
rs 10
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