PresenterSubscriber   A
last analyzed

Complexity

Total Complexity 3

Size/Duplication

Total Lines 30
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 1

Importance

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

3 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 4 1
A getSubscribedEvents() 0 4 1
A onShutdown() 0 4 1
1
<?php
2
3
namespace Symnedi\EventDispatcher\Tests\NetteEvent\EventSubscriber;
4
5
use Symfony\Component\EventDispatcher\EventSubscriberInterface;
6
use Symnedi\EventDispatcher\Event\PresenterResponseEvent;
7
use Symnedi\EventDispatcher\NettePresenterEvents;
8
use Symnedi\EventDispatcher\Tests\NetteEvent\EventStateStorage;
9
10
11
final class PresenterSubscriber implements EventSubscriberInterface
12
{
13
14
	/**
15
	 * @var EventStateStorage
16
	 */
17
	private $eventStateStorage;
18
19
20
	public function __construct(EventStateStorage $eventStateStorage)
21
	{
22
		$this->eventStateStorage = $eventStateStorage;
23
	}
24
25
26
	/**
27
	 * {@inheritdoc}
28
	 */
29
	public static function getSubscribedEvents()
30
	{
31
		return [NettePresenterEvents::ON_SHUTDOWN => 'onShutdown'];
32
	}
33
34
35
	public function onShutdown(PresenterResponseEvent $presenterResponseEvent)
36
	{
37
		$this->eventStateStorage->addEventState(NettePresenterEvents::ON_SHUTDOWN, $presenterResponseEvent);
38
	}
39
40
}
41