Test Failed
Push — develop ( 50f9bb...e90cf2 )
by nguereza
02:33
created

LogoutAction   A

Complexity

Total Complexity 2

Size/Duplication

Total Lines 44
Duplicated Lines 0 %

Importance

Changes 0
Metric Value
eloc 22
dl 0
loc 44
rs 10
c 0
b 0
f 0
wmc 2

2 Methods

Rating   Name   Duplication   Size   Complexity  
A handle() 0 11 1
A __construct() 0 18 1
1
<?php
2
3
namespace Platine\Framework\Demo\Action;
4
5
use Platine\Cache\CacheInterface;
6
use Platine\Config\Config;
7
use Platine\Cookie\CookieManagerInterface;
8
use Platine\Framework\App\Application;
9
use Platine\Framework\Demo\Repository\UserRepository;
10
use Platine\Http\Handler\RequestHandlerInterface;
11
use Platine\Http\Response;
12
use Platine\Http\ResponseInterface;
13
use Platine\Http\ServerRequestInterface;
14
use Platine\Logger\LoggerInterface;
15
use Platine\Session\Session;
16
use Platine\Template\Template;
17
18
/**
19
 * Description of LogoutAction
20
 *
21
 * @author tony
22
 */
23
class LogoutAction implements RequestHandlerInterface
24
{
25
26
    protected LoggerInterface $logger;
27
    protected Application $app;
28
    protected Config $config;
29
    protected Session $session;
30
    protected UserRepository $userRepository;
31
    protected Template $template;
32
    protected CookieManagerInterface $cookieManager;
33
    protected CacheInterface $cache;
34
35
36
    public function __construct(
37
        LoggerInterface $logger,
38
        Application $app,
39
        Config $config,
40
        Session $session,
41
        Template $template,
42
        UserRepository $userRepository,
43
        CookieManagerInterface $cookieManager,
44
        CacheInterface $cache
45
    ) {
46
        $this->logger = $logger;
47
        $this->app = $app;
48
        $this->config = $config;
49
        $this->session = $session;
50
        $this->userRepository = $userRepository;
51
        $this->template = $template;
52
        $this->cookieManager = $cookieManager;
53
        $this->cache = $cache;
54
    }
55
56
    public function handle(ServerRequestInterface $request): ResponseInterface
57
    {
58
        $this->session->remove('user');
59
60
        $res = new Response();
61
62
        $res->getBody()
63
                ->write('You are successfully logout 
64
                    <br /><a href = \'login\'>Login Page</a>');
65
66
        return $res;
67
    }
68
}
69