Passed
Push — master ( 8b4203...c04040 )
by Nashwan
02:43 queued 10s
created

EventManagerFactory::__invoke()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 6
Code Lines 3

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
cc 1
eloc 3
nc 1
nop 1
dl 0
loc 6
rs 10
c 1
b 0
f 0
1
<?php
2
/**
3
 * @package EBloodBank
4
 * @since   1.6
5
 */
6
namespace EBloodBank;
7
8
use Psr\Container\ContainerInterface;
9
10
/**
11
 * @since 1.6
12
 */
13
class EventManagerFactory
14
{
15
    /**
16
     * @param  ContainerInterface $container
17
     * @return EventManager
18
     * @since  1.6
19
     */
20
    public function __invoke(ContainerInterface $container)
21
    {
22
        $eventManager = new EventManager();
23
        $this->addEventListener($eventManager, $container);
24
25
        return $eventManager;
26
    }
27
28
    /**
29
     * @param  EventManager $eventManager
30
     * @param  ContainerInterface $container
31
     * @return void
32
     * @since  1.6
33
     */
34
    protected function addEventListener(EventManager $eventManager, ContainerInterface $container)
35
    {
36
        $emailNotificationListener = Listeners\EmailNotificationListener::factory($container);
37
        $eventManager->getEventDispatcher()->addListener('user.created', $emailNotificationListener);
38
        $eventManager->getEventDispatcher()->addListener('donor.created', $emailNotificationListener);
39
    }
40
}
41