Test Failed
Push — develop ( c3d980...50f9bb )
by nguereza
02:14
created

LogoutAction::handle()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 11
Code Lines 5

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
cc 1
eloc 5
c 1
b 0
f 0
nc 1
nop 1
dl 0
loc 11
rs 10
1
<?php
2
3
namespace Platine\Framework\Demo;
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