LogOut   A
last analyzed

Complexity

Total Complexity 6

Size/Duplication

Total Lines 35
Duplicated Lines 0 %

Importance

Changes 0
Metric Value
eloc 17
dl 0
loc 35
rs 10
c 0
b 0
f 0
wmc 6

1 Method

Rating   Name   Duplication   Size   Complexity  
A close() 0 28 6
1
<?php
2
3
namespace Auth\Controller;
4
5
use Drone\Mvc\AbstractionController;
6
use Drone\Network\Http;
7
8
class LogOut extends AbstractionController
9
{
10
    /**
11
     * Closes the user session
12
     *
13
     * @return null
14
     */
15
    public function close()
16
    {
17
        # STANDARD VALIDATIONS [check method]
18
        if (!$this->isGet())
19
        {
20
            $http = new Http();
21
            $http->writeStatus($http::HTTP_METHOD_NOT_ALLOWED);
22
23
            die('Error ' . $http::HTTP_METHOD_NOT_ALLOWED .' (' . $http->getStatusText($http::HTTP_METHOD_NOT_ALLOWED) . ')!!');
0 ignored issues
show
Best Practice introduced by
Using exit here is not recommended.

In general, usage of exit should be done with care and only when running in a scripting context like a CLI script.

Loading history...
24
        }
25
26
        $config = include 'module/Auth/config/user.config.php';
27
        $method = $config["authentication"]["method"];
28
        $key    = $config["authentication"]["key"];
29
30
        switch ($method)
31
        {
32
            case '_COOKIE':
33
                if (array_key_exists($key, $_COOKIE) || !empty($_COOKIE[$key]))
34
                    setcookie($key, $_COOKIE[$key], time() - 1, '/');
35
                break;
36
37
            case '_SESSION':
38
                session_destroy();
39
                break;
40
        }
41
42
        header("location: " . $this->getBasePath() . "/public/Auth");
43
    }
44
}