Session   A
last analyzed

Complexity

Total Complexity 4

Size/Duplication

Total Lines 41
Duplicated Lines 0 %

Importance

Changes 0
Metric Value
eloc 9
dl 0
loc 41
rs 10
c 0
b 0
f 0
wmc 4

3 Methods

Rating   Name   Duplication   Size   Complexity  
A obtainRunSession() 0 5 1
A __construct() 0 11 2
A __invoke() 0 3 1
1
<?php
2
3
namespace BFW\Core\AppSystems;
4
5
class Session extends AbstractSystem
6
{
7
    /**
8
     * Initialize sessions system
9
     * Automaticaly destroy cookie if browser quit and start sessions
10
     * 
11
     * @return void
12
     */
13
    public function __construct()
14
    {
15
        if ($this->obtainRunSession() === false) {
16
            return;
17
        }
18
19
        //Destroy session cookie if browser quit
20
        session_set_cookie_params(0);
21
22
        //Run session
23
        session_start();
24
    }
25
    
26
    /**
27
     * {@inheritdoc}
28
     * 
29
     * @return null
30
     */
31
    public function __invoke()
32
    {
33
        return null;
34
    }
35
    
36
    /**
37
     * Obtain the value of the option runSession passed to Application
38
     * 
39
     * @return boolean
40
     */
41
    protected function obtainRunSession(): bool
42
    {
43
        return \BFW\Application::getInstance()
44
            ->getOptions()
45
            ->getValue('runSession')
46
        ;
47
    }
48
}
49