NotificationSubscriber::notify()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 4

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 3
CRAP Score 1

Importance

Changes 0
Metric Value
dl 0
loc 4
ccs 3
cts 3
cp 1
rs 10
c 0
b 0
f 0
cc 1
nc 1
nop 1
crap 1
1
<?php
2
3
namespace JK\SamBundle\Event\Subscriber;
4
5
use JK\Sam\Event\NotificationEvent;
6
use Symfony\Component\EventDispatcher\EventSubscriberInterface;
7
8
class NotificationSubscriber implements EventSubscriberInterface
9
{
10
    /**
11
     * @var array
12
     */
13
    protected $notifications = [];
14
15
    /**
16
     * @return array
17
     */
18 1
    public static function getSubscribedEvents()
19
    {
20
        return [
21 1
            NotificationEvent::NAME => 'notify'
22
        ];
23
    }
24
25
    /**
26
     * @param NotificationEvent $event
27
     */
28 1
    public function notify(NotificationEvent $event)
29
    {
30 1
        $this->notifications[] = $event->getMessage();
31 1
    }
32
33
    /**
34
     * @return array
35
     */
36 1
    public function getNotifications()
37
    {
38 1
        return $this->notifications;
39
    }
40
41
    /**
42
     * 
43
     */
44 1
    public function clearNotifications()
45
    {
46 1
        $this->notifications = [];
47 1
    }
48
}
49