Issues (62)

Service/Jwt.php (1 issue)

1
<?php
2
3
namespace PiouPiou\RibsAdminBundle\Service;
4
5
use \Firebase\JWT\JWT as JsonWebToken;
6
7
class Jwt
8
{
9
	/**
10
     * encode an array in jwt
11
	 * @param array $values
12
	 * @param string $token
13
	 * @return string
14
	 */
15
	public static function encode(array $values, string $token)
16
	{
17
		return JsonWebToken::encode($values, $token);
18
	}
19
	
20
	/**
21
     * encode a jwt in array
22
	 * @param string $encoded_json
23
	 * @param string $token
24
	 * @return bool|object
25
	 */
26
	public static function decode(string $encoded_json, string $token)
27
	{
28
		JsonWebToken::$leeway = 5;
29
		$decoded = JsonWebToken::decode($encoded_json, $token, ['HS256']);
30
		
31
		if ($decoded) {
0 ignored issues
show
$decoded is of type object, thus it always evaluated to true.
Loading history...
32
			return $decoded;
33
		}
34
		
35
		return false;
36
	}
37
}
38