Passed
Push — master ( fd01cd...a8d522 )
by Alexandre
02:26
created

AccessToken::getToken()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 3
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 0
CRAP Score 2

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
ccs 0
cts 0
cp 0
crap 2
1
<?php
2
/**
3
 * Created by PhpStorm.
4
 * User: Alexandre
5
 * Date: 07/03/2018
6
 * Time: 22:55
7
 */
8
9
namespace OAuth2\Credentials;
10
11
12
class AccessToken implements AccessTokenInterface
13
{
14
    /**
15
     * @var string
16
     */
17
    protected $token;
18
    /**
19
     * @var string
20
     */
21
    protected $scope;
22
    /**
23
     * @var string
24
     */
25
    protected $clientIdentifier;
26
    /**
27
     * @var string
28
     */
29
    protected $resourceOwnerIdentifier;
30
    /**
31
     * @var int
32
     */
33
    protected $expiresAt;
34
    /**
35
     * @var string
36
     */
37
    protected $authorizationCode;
38
39
    public function __construct(string $token, string $scope, string $clientIdentifier, string $resourceOwnerIdentifier,
40
                                int $expiresAt, ?string $authorizationCode = null)
41
    {
42
        $this->token = $token;
43
        $this->scope = $scope;
44
        $this->clientIdentifier = $clientIdentifier;
45
        $this->resourceOwnerIdentifier = $resourceOwnerIdentifier;
46
        $this->expiresAt = $expiresAt;
47
        $this->authorizationCode = $authorizationCode;
48
    }
49
50
    /**
51
     * @return string
52
     */
53
    public function getToken(): string
54
    {
55
        return $this->token;
56 2
    }
57
58 2
    public function getType(): string
59 2
    {
60 2
        return 'bearer';
61
    }
62 2
63
    /**
64
     * @return string
65
     */
66
    public function getScope(): string
67
    {
68
        return $this->scope;
69
    }
70
71
    /**
72
     * @return string
73
     */
74
    public function getClientIdentifier(): string
75
    {
76
        return $this->clientIdentifier;
77
    }
78
79
    /**
80
     * @return string
81
     */
82
    public function getResourceOwnerIdentifier(): string
83
    {
84
        return $this->resourceOwnerIdentifier;
85
    }
86
87
    public function isExpired(): bool
88
    {
89
        return time() > $this->expiresAt;
90
    }
91 2
92
    /**
93 2
     * @return string
94 2
     */
95 2
    public function getAuthorizationCode(): string
96 2
    {
97 2
        return $this->authorizationCode;
98
    }
99
}