Passed
Branch main (166306)
by Nelson
03:35
created

LogoutHandler   A

Complexity

Total Complexity 3

Size/Duplication

Total Lines 17
Duplicated Lines 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
eloc 8
dl 0
loc 17
rs 10
c 1
b 0
f 0
wmc 3

2 Methods

Rating   Name   Duplication   Size   Complexity  
A handle() 0 8 2
A redirect() 0 4 1
1
<?php
2
3
namespace App\Handlers;
4
5
use App\Libs\Session;
6
7
/**
8
 * LoginHandler
9
 * Handler para la autenticación
10
 */
11
class LogoutHandler extends Handler
12
{
13
    public function handle(array $params = [])
14
    {
15
        $action = $_SERVER['REQUEST_METHOD'];
16
        
17
        if ($action === 'GET') {
18
            Session::destroy();
19
            Session::set("flash", "Adios!");
20
            $this->redirect("");
21
        }
22
    }
23
24
    private function redirect($path)
25
    {
26
        $url = PUBLIC_PATH . $path;
27
        header("Location: $url", true, 301);
28
    }
29
}
30