Completed
Push — master ( ac0f4a...8c1ab9 )
by Adam
02:42
created

OnAfterIncomingMessageHandler::__construct()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 5
Code Lines 3

Duplication

Lines 5
Ratio 100 %

Code Coverage

Tests 0
CRAP Score 2

Importance

Changes 0
Metric Value
dl 5
loc 5
ccs 0
cts 2
cp 0
rs 9.4285
c 0
b 0
f 0
cc 1
eloc 3
nc 1
nop 1
crap 2
1
<?php
2
/**
3
 * OnAfterIncomingMessageHandler.php
4
 *
5
 * @copyright      More in license.md
6
 * @license        http://www.ipublikuj.eu
7
 * @author         Adam Kadlec http://www.ipublikuj.eu
8
 * @package        iPublikuj:WebSocketSession!
9
 * @subpackage     Events
10
 * @since          1.0.0
11
 *
12
 * @date           05.03.17
13
 */
14
15
declare(strict_types = 1);
16
17
namespace IPub\WebSocketsSession\Events;
18
19
use Nette;
20
21
use IPub;
22
use IPub\WebSocketsSession\Session;
23
24
use IPub\WebSockets\Entities as WebSocketsEntities;
25
use IPub\WebSockets\Http as WebSocketsHttp;
26
27
/**
28
 * This component will allow access to session data from your Nette Framework website for each user connected
29
 *
30
 * @package        iPublikuj:WebSocketSession!
31
 * @subpackage     Events
32
 *
33
 * @author         Adam Kadlec <[email protected]>
34
 */
35 1 View Code Duplication
final class OnAfterIncomingMessageHandler
0 ignored issues
show
Duplication introduced by
This class seems to be duplicated in your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
36
{
37
	/**
38
	 * Implement nette smart magic
39
	 */
40 1
	use Nette\SmartObject;
41
42
	/**
43
	 * @var Session\SwitchableSession
44
	 */
45
	private $session;
46
47
	/**
48
	 * @param Session\SwitchableSession $session
49
	 */
50
	public function __construct(
51
		Session\SwitchableSession $session
52
	) {
53
		$this->session = $session;
54
	}
55
56
	/**
57
	 * @param WebSocketsEntities\Clients\IClient $from
58
	 * @param WebSocketsHttp\IRequest $httpRequest
59
	 *
60
	 * @return void
61
	 */
62
	public function __invoke(WebSocketsEntities\Clients\IClient $from, WebSocketsHttp\IRequest $httpRequest)
63
	{
64
		if ($this->session instanceof Session\SwitchableSession) {
65
			$this->session->detach();
66
		}
67
	}
68
}
69