Test Failed
Pull Request — master (#62)
by
unknown
05:03
created

ResponseCookieTokenSetterEventListener   A

Complexity

Total Complexity 2

Size/Duplication

Total Lines 13
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 2

Importance

Changes 0
Metric Value
wmc 2
c 0
b 0
f 0
lcom 1
cbo 2
dl 0
loc 13
rs 10

2 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 4 1
A onAddToken() 0 5 1
1
<?php 
2
3
/*
4
 * This file is part of the GesdinetJWTRefreshTokenBundle package.
5
 *
6
 * (c) Gesdinet <http://www.gesdinet.com/>
7
 *
8
 * For the full copyright and license information, please view the LICENSE
9
 * file that was distributed with this source code.
10
 */
11
12
namespace Gesdinet\JWTRefreshTokenBundle\EventListener\TokenSetter;
13
14
use Gesdinet\JWTRefreshTokenBundle\Event\AddTokenResponseEvent;
15
use Symfony\Component\HttpFoundation\Cookie;
16
17
class ResponseCookieTokenSetterEventListener {
18
	private $name;
19
	private $ttl;
20
	public function __construct($name, $ttl){
21
		$this->name = $name;
22
		$this->ttl = $ttl;
23
	}
24
	public function onAddToken(AddTokenResponseEvent $event){
25
		$response = $event->getResponse();
26
		$token = $event->getToken();
27
		$response->headers->setCookie(new Cookie($this->name, $token, time() + $this->ttl, '/', null, false, true));
28
	}
29
}