NotificationSubscriber   A
last analyzed

Complexity

Total Complexity 3

Size/Duplication

Total Lines 22
Duplicated Lines 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
wmc 3
eloc 6
c 1
b 0
f 0
dl 0
loc 22
rs 10

3 Methods

Rating   Name   Duplication   Size   Complexity  
A getSubscribedEvents() 0 4 1
A __construct() 0 3 1
A createNotification() 0 3 1
1
<?php
2
3
namespace JK\NotificationBundle\Event\Subscriber;
4
5
use JK\NotificationBundle\Event\Events;
6
use JK\NotificationBundle\Event\NotificationEvent;
7
use JK\NotificationBundle\Manager\NotificationManagerInterface;
8
use Symfony\Component\EventDispatcher\EventSubscriberInterface;
9
10
class NotificationSubscriber implements EventSubscriberInterface
11
{
12
    /**
13
     * @var NotificationManagerInterface
14
     */
15
    private $manager;
16
17
    public static function getSubscribedEvents()
18
    {
19
        return [
20
            Events::NOTIFY => 'createNotification',
21
        ];
22
    }
23
24
    public function __construct(NotificationManagerInterface $manager)
25
    {
26
        $this->manager = $manager;
27
    }
28
29
    public function createNotification(NotificationEvent $event): void
30
    {
31
        $this->manager->create($event->getTitle(), $event->getContent(), $event->getOwnerId());
32
    }
33
}
34