Jwt   A
last analyzed

Complexity

Total Complexity 3

Size/Duplication

Total Lines 29
Duplicated Lines 0 %

Importance

Changes 2
Bugs 0 Features 1
Metric Value
eloc 7
c 2
b 0
f 1
dl 0
loc 29
rs 10
wmc 3

2 Methods

Rating   Name   Duplication   Size   Complexity  
A encode() 0 3 1
A decode() 0 10 2
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
introduced by
$decoded is of type object, thus it always evaluated to true.
Loading history...
32
			return $decoded;
33
		}
34
		
35
		return false;
36
	}
37
}
38