Passed
Push — master ( 06a7ac...ba6e27 )
by Dāvis
11:11
created

AccessToken::getIdTokenHint()   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 0
dl 0
loc 3
rs 10
c 0
b 0
f 0
1
<?php
2
3
namespace Sludio\HelperBundle\Openidconnect\Provider;
4
5
use Lcobucci\JWT\Parser;
6
use League\OAuth2\Client\Token\AccessToken as BaseAccessToken;
7
8
class AccessToken extends BaseAccessToken
9
{
10
    protected $idToken;
11
12
    protected $idTokenHint;
13
14
    public function __construct(array $options = [])
15
    {
16
        parent::__construct($options);
17
18
        if (!empty($this->values['id_token'])) {
19
            $this->idToken = (new Parser())->parse($this->values['id_token']);
20
            $this->idTokenHint = $this->values['id_token'];
21
            unset($this->values['id_token']);
22
        }
23
    }
24
25
    public function getIdToken()
26
    {
27
        return $this->idToken;
28
    }
29
30
    public function jsonSerialize()
31
    {
32
        $parameters = parent::jsonSerialize();
33
        if ($this->idToken) {
34
            $parameters['id_token'] = (string)$this->idToken;
35
        }
36
37
        return $parameters;
38
    }
39
40
    /**
41
     * @return mixed
42
     */
43
    public function getIdTokenHint()
44
    {
45
        return $this->idTokenHint;
46
    }
47
}
48