Completed
Push — master ( de901a...efbe60 )
by Derek Stephen
04:42
created

AuthCode   A

Complexity

Total Complexity 12

Size/Duplication

Total Lines 145
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 1

Importance

Changes 0
Metric Value
wmc 12
lcom 1
cbo 1
dl 0
loc 145
rs 10
c 0
b 0
f 0

12 Methods

Rating   Name   Duplication   Size   Complexity  
A getIdentifier() 0 4 1
A setIdentifier() 0 4 1
A addScope() 0 4 1
A getScopes() 0 4 1
A getExpiryDateTime() 0 4 1
A setExpiryDateTime() 0 4 1
A setUserIdentifier() 0 4 1
A getUserIdentifier() 0 4 1
A getClient() 0 4 1
A setClient() 0 4 1
A getRedirectUri() 0 4 1
A setRedirectUri() 0 4 1
1
<?php
2
3
namespace OAuth;
4
5
use DateTime;
6
use League\OAuth2\Server\Entities\AuthCodeEntityInterface;
7
use League\OAuth2\Server\Entities\ClientEntityInterface;
8
use League\OAuth2\Server\Entities\ScopeEntityInterface;
9
10
class AuthCode implements AuthCodeEntityInterface
11
{
12
13
    /**
14
     * @var null|string
15
     */
16
    protected $redirectUri;
17
18
    /**
19
     * @var ScopeEntityInterface[]
20
     */
21
    protected $scopes = [];
22
23
    /**
24
     * @var \DateTime
25
     */
26
    protected $expiryDateTime;
27
28
    /**
29
     * @var string|int
30
     */
31
    protected $userIdentifier;
32
33
    /**
34
     * @var ClientEntityInterface
35
     */
36
    protected $client;
37
38
    /**
39
     * @var string
40
     */
41
    protected $identifier;
42
43
    /**
44
     * @return mixed
45
     */
46
    public function getIdentifier()
47
    {
48
        return $this->identifier;
49
    }
50
51
    /**
52
     * @param mixed $identifier
53
     */
54
    public function setIdentifier($identifier)
55
    {
56
        $this->identifier = $identifier;
57
    }
58
59
    /**
60
     * Associate a scope with the token.
61
     *
62
     * @param ScopeEntityInterface $scope
63
     */
64
    public function addScope(ScopeEntityInterface $scope)
65
    {
66
        $this->scopes[$scope->getIdentifier()] = $scope;
67
    }
68
69
    /**
70
     * Return an array of scopes associated with the token.
71
     *
72
     * @return ScopeEntityInterface[]
73
     */
74
    public function getScopes()
75
    {
76
        return array_values($this->scopes);
77
    }
78
79
    /**
80
     * Get the token's expiry date time.
81
     *
82
     * @return \DateTime
83
     */
84
    public function getExpiryDateTime()
85
    {
86
        return $this->expiryDateTime;
87
    }
88
89
    /**
90
     * Set the date time when the token expires.
91
     *
92
     * @param DateTime $dateTime
93
     */
94
    public function setExpiryDateTime(DateTime $dateTime)
95
    {
96
        $this->expiryDateTime = $dateTime;
97
    }
98
99
    /**
100
     * Set the identifier of the user associated with the token.
101
     *
102
     * @param string|int $identifier The identifier of the user
103
     */
104
    public function setUserIdentifier($identifier)
105
    {
106
        $this->userIdentifier = $identifier;
107
    }
108
109
    /**
110
     * Get the token user's identifier.
111
     *
112
     * @return string|int
113
     */
114
    public function getUserIdentifier()
115
    {
116
        return $this->userIdentifier;
117
    }
118
119
    /**
120
     * Get the client that the token was issued to.
121
     *
122
     * @return ClientEntityInterface
123
     */
124
    public function getClient()
125
    {
126
        return $this->client;
127
    }
128
129
    /**
130
     * Set the client that the token was issued to.
131
     *
132
     * @param ClientEntityInterface $client
133
     */
134
    public function setClient(ClientEntityInterface $client)
135
    {
136
        $this->client = $client;
137
    }
138
139
    /**
140
     * @return string
141
     */
142
    public function getRedirectUri()
143
    {
144
        return $this->redirectUri;
145
    }
146
147
    /**
148
     * @param string $uri
149
     */
150
    public function setRedirectUri($uri)
151
    {
152
        $this->redirectUri = $uri;
153
    }
154
}