Failed Conditions
Push — master ( 8d4434...bd8ce1 )
by Florent
04:25
created

OAuth2Token::__construct()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 5
Code Lines 3

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 5
rs 9.4285
c 0
b 0
f 0
cc 1
eloc 3
nc 1
nop 1
1
<?php
2
3
declare(strict_types=1);
4
5
/*
6
 * The MIT License (MIT)
7
 *
8
 * Copyright (c) 2014-2017 Spomky-Labs
9
 *
10
 * This software may be modified and distributed under the terms
11
 * of the MIT license.  See the LICENSE file for details.
12
 */
13
14
namespace OAuth2Framework\Bundle\Server\Security\Authentication\Token;
15
16
use OAuth2Framework\Component\Server\Model\AccessToken\AccessToken;
17
use Symfony\Component\Security\Core\Authentication\Token\AbstractToken;
18
19
final class OAuth2Token extends AbstractToken
20
{
21
    /**
22
     * @var AccessToken
23
     */
24
    private $accessToken;
25
26
    public function __construct(AccessToken $accessToken)
27
    {
28
        parent::__construct();
29
        $this->accessToken = $accessToken;
30
    }
31
32
    /**
33
     * @return string
34
     */
35
    public function getToken(): string
36
    {
37
        return $this->accessToken->getTokenId()->getValue();
38
    }
39
40
    /**
41
     * @return AccessToken
42
     */
43
    public function getAccessToken(): AccessToken
44
    {
45
        return $this->accessToken;
46
    }
47
48
    /**
49
     * @return string
50
     */
51
    public function getClientId(): string
52
    {
53
        return $this->accessToken->getClientId()->getValue();
54
    }
55
56
    /**
57
     * @return string
58
     */
59
    public function getResourceOwnerId(): string
60
    {
61
        return $this->accessToken->getResourceOwnerId()->getValue();
62
    }
63
64
    /**
65
     * {@inheritdoc}
66
     */
67
    public function getCredentials()
68
    {
69
        return $this->getToken();
70
    }
71
}
72