EventServiceProvider::register()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 10
Code Lines 7

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 0
CRAP Score 2

Importance

Changes 1
Bugs 1 Features 0
Metric Value
cc 1
eloc 7
nc 1
nop 1
dl 0
loc 10
ccs 0
cts 10
cp 0
crap 2
rs 9.4285
c 1
b 1
f 0
1
<?php
2
namespace Wandu\Event;
3
4
use Wandu\DI\ContainerInterface;
5
use Wandu\DI\ServiceProviderInterface;
6
use Wandu\Event\Contracts\EventEmitter as EventEmitterContract;
7
use Wandu\Q\Worker;
8
9
class EventServiceProvider implements ServiceProviderInterface
10
{
11
    /** @var array */
12
    protected $listeners = [
13
    ];
14
15
    /**
16
     * {@inheritdoc}
17
     */
18
    public function register(ContainerInterface $app)
19
    {
20
        $app->closure(EventEmitter::class, function (ContainerInterface $container, Worker $worker) {
21
            $emitter = new EventEmitter($this->listeners);
22
            $emitter->setContainer($container);
23
            $emitter->setWorker($worker);
24
            return $emitter;
25
        });
26
        $app->alias(EventEmitterContract::class, EventEmitter::class);
27
    }
28
29
    /**
30
     * {@inheritdoc}
31
     */
32
    public function boot(ContainerInterface $app)
33
    {
34
    }
35
}
36