Passed
Push — master ( cd0cec...4b3abd )
by Alexandre
06:20
created

IdTokenManager   A

Complexity

Total Complexity 2

Size/Duplication

Total Lines 19
Duplicated Lines 0 %

Importance

Changes 0
Metric Value
wmc 2
dl 0
loc 19
rs 10
c 0
b 0
f 0

2 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 3 1
A decode() 0 5 1
1
<?php
2
/**
3
 * Created by PhpStorm.
4
 * User: Alexandre
5
 * Date: 14/03/2018
6
 * Time: 21:48
7
 */
8
9
namespace OAuth2\Extensions\OpenID;
10
11
12
use Firebase\JWT\JWT;
13
use OAuth2\IdToken;
14
use OAuth2\IdTokenInterface;
15
16
class IdTokenManager
17
{
18
    const KEY = 'AZE'; // Keys storage ? manager ?
19
20
    /**
21
     * @var JWT
22
     */
23
    private $jwt;
24
25
    public function __construct(JWT $jwt)
26
    {
27
        $this->jwt = $jwt;
28
    }
29
30
    public function decode(string $idToken): IdTokenInterface
31
    {
32
        $claims = $this->jwt->decode($idToken, self::KEY, 'HS256');
0 ignored issues
show
Bug introduced by
'HS256' of type string is incompatible with the type array expected by parameter $allowed_algs of Firebase\JWT\JWT::decode(). ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-type  annotation

32
        $claims = $this->jwt->decode($idToken, self::KEY, /** @scrutinizer ignore-type */ 'HS256');
Loading history...
33
        $idToken = new IdToken((array) $claims);
34
        return $idToken;
35
    }
36
}