Session   A
last analyzed

Complexity

Total Complexity 2

Size/Duplication

Total Lines 29
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 1

Test Coverage

Coverage 100%

Importance

Changes 0
Metric Value
wmc 2
lcom 0
cbo 1
dl 0
loc 29
ccs 12
cts 12
cp 1
rs 10
c 0
b 0
f 0

1 Method

Rating   Name   Duplication   Size   Complexity  
A autorun() 0 20 2
1
<?php
2
namespace Redaxscript\Bootstrap;
3
4
use Redaxscript\Server;
5
use function session_id;
6
use function session_regenerate_id;
7
use function session_set_cookie_params;
8
use function session_start;
9
use function session_status;
10
11
/**
12
 * children class to boot the session
13
 *
14
 * @since 3.1.0
15
 *
16
 * @package Redaxscript
17
 * @category Bootstrap
18
 * @author Henry Ruhs
19
 */
20
21
class Session extends BootstrapAbstract
22
{
23
	/**
24
	 * automate run
25
	 *
26
	 * @since 3.1.0
27
	 */
28
29 1
	public function autorun() : void
30
	{
31 1
		$protocol = new Server\Protocol($this->_request);
32 1
		session_set_cookie_params(
33
		[
34 1
			'samesite' => 'strict',
35 1
			'secure' => $protocol->getOutput() === 'https'
36
		]);
37 1
		session_start();
38 1
		$this->_request->refreshSession();
39
40
		/* session guard */
41
42 1
		if (!$this->_request->getSession('sessionGuard'))
43
		{
44 1
			$this->_request->setSession('sessionGuard', session_regenerate_id());
45
		}
46 1
		$this->_registry->set('sessionId', session_id());
47 1
		$this->_registry->set('sessionStatus', session_status());
48 1
	}
49
}
50