EventServiceProvider   A
last analyzed

Complexity

Total Complexity 4

Size/Duplication

Total Lines 37
Duplicated Lines 0 %

Test Coverage

Coverage 81.25%

Importance

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

4 Methods

Rating   Name   Duplication   Size   Complexity  
A register() 0 3 1
A registerDispatcher() 0 4 1
A boot() 0 5 1
A provides() 0 7 1
1
<?php
2
3
namespace ByTIC\EventDispatcher;
4
5
use ByTIC\EventDispatcher\Discovery\RegisterDiscoveredEvents;
6
use ByTIC\EventDispatcher\Dispatcher\EventDispatcher;
7
use ByTIC\EventDispatcher\Dispatcher\EventDispatcherInterface;
8
use Nip\Container\ServiceProviders\Providers\AbstractSignatureServiceProvider;
9
use Nip\Container\ServiceProviders\Providers\BootableServiceProviderInterface;
10
use Psr\EventDispatcher\EventDispatcherInterface as PsrEventDispatcherInterface;
11
use Symfony\Component\EventDispatcher\EventDispatcherInterface as SymfonyEventDispatcherInterface;
12
13
/**
14
 * Class EventServiceProvider
15
 * @package ByTIC\EventDispatcher
16
 */
17
class EventServiceProvider extends AbstractSignatureServiceProvider implements BootableServiceProviderInterface
18
{
19 3
    public const DIPATCHER_NAME = 'events';
20
21 3
    /**
22 3
     * @inheritdoc
23 3
     */
24
    public function register()
25 3
    {
26
        $this->registerDispatcher();
27
    }
28
29 3
    public function boot()
30 3
    {
31
        $dispatcher = $this->getContainer()->get(static::DIPATCHER_NAME);
32 3
        $provider = new RegisterDiscoveredEvents($dispatcher);
33
        $provider->register();
34 3
    }
35 3
36
    protected function registerDispatcher()
37
    {
38
        $this->getContainer()->share('events', function () {
39 2
            return new EventDispatcher();
40 3
        });
41 3
    }
42
43
44
    /**
45
     * @inheritdoc
46
     */
47
    public function provides(): array
48
    {
49
        return [
50
            self::DIPATCHER_NAME,
51
            EventDispatcherInterface::class,
52
            PsrEventDispatcherInterface::class,
53
            SymfonyEventDispatcherInterface::class
54
        ];
55
    }
56
}
57