Passed
Push — master ( 81b196...c30d9d )
by Anthony
02:43
created

Jwt::encode()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 3
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 1
eloc 1
nc 1
nop 2
dl 0
loc 3
rs 10
c 0
b 0
f 0
1
<?php
2
3
namespace PiouPiou\RibsAdminBundle\Service;
4
5
use \Firebase\JWT\JWT as JsonWebToken;
0 ignored issues
show
Bug introduced by
The type Firebase\JWT\JWT was not found. Maybe you did not declare it correctly or list all dependencies?

The issue could also be caused by a filter entry in the build configuration. If the path has been excluded in your configuration, e.g. excluded_paths: ["lib/*"], you can move it to the dependency path list as follows:

filter:
    dependency_paths: ["lib/*"]

For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths

Loading history...
6
7
class Jwt
8
{
9
	/**
10
	 * @param array $values
11
	 * @param string $token
12
	 * @return string
13
	 * encode an array in jwt
14
	 */
15
	public function encode(array $values, string $token)
16
	{
17
		return JsonWebToken::encode($values, $token);
18
	}
19
	
20
	/**
21
	 * @param string $encoded_json
22
	 * @param string $token
23
	 * @return bool|object
24
	 * encode a jwt in array
25
	 */
26
	public function decode(string $encoded_json, string $token)
27
	{
28
		$decoded = JsonWebToken::decode($encoded_json, $token, ['HS256']);
29
		
30
		if ($decoded) {
31
			return $decoded;
32
		}
33
		
34
		return false;
35
	}
36
}
37