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

AccessToken   A

Complexity

Total Complexity 8

Size/Duplication

Total Lines 86
Duplicated Lines 0 %

Test Coverage

Coverage 100%

Importance

Changes 0
Metric Value
dl 0
loc 86
rs 10
c 0
b 0
f 0
ccs 11
cts 11
cp 1
wmc 8

8 Methods

Rating   Name   Duplication   Size   Complexity  
A getClientIdentifier() 0 3 1
A getScope() 0 3 1
A getToken() 0 3 1
A __construct() 0 9 1
A getAuthorizationCode() 0 3 1
A isExpired() 0 3 1
A getResourceOwnerIdentifier() 0 3 1
A getType() 0 3 1
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
}