Completed
Push — master ( 25ba26...942c9a )
by dan
02:00
created

MessageCRUDSubscriber   A

Complexity

Total Complexity 3

Size/Duplication

Total Lines 22
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 2

Importance

Changes 0
Metric Value
wmc 3
lcom 1
cbo 2
dl 0
loc 22
rs 10
c 0
b 0
f 0

3 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 4 1
A onMessageCreated() 0 5 1
A getSubscribedEvents() 0 6 1
1
<?php
2
3
namespace IrishDan\NotificationBundle\EventListener;
4
5
use IrishDan\NotificationBundle\Channel\EventChannel;
6
use IrishDan\NotificationBundle\Event\MessageCreatedEvent;
7
use Symfony\Component\EventDispatcher\EventSubscriberInterface;
8
9
class MessageCRUDSubscriber implements EventSubscriberInterface
10
{
11
    private $eventChannel;
12
13
    public function __construct(EventChannel $eventChannel)
14
    {
15
        $this->eventChannel = $eventChannel;
16
    }
17
18
    public function onMessageCreated(MessageCreatedEvent $event)
19
    {
20
        $message = $event->getMessage();
21
        $this->eventChannel->dispatch($message);
22
    }
23
24
    public static function getSubscribedEvents()
25
    {
26
        return [
27
            MessageCreatedEvent::NAME => 'onMessageCreated',
28
        ];
29
    }
30
}
31