NotificationSubscriber::__construct()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 3
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
eloc 1
c 1
b 0
f 0
dl 0
loc 3
rs 10
cc 1
nc 1
nop 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