Completed
Push — master ( 88b001...24ab37 )
by Derek Stephen
10:51
created

AccessToken::getClientId()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 2

Duplication

Lines 4
Ratio 100 %

Code Coverage

Tests 0
CRAP Score 2

Importance

Changes 0
Metric Value
dl 4
loc 4
ccs 0
cts 2
cp 0
rs 10
c 0
b 0
f 0
cc 1
eloc 2
nc 1
nop 0
crap 2
1
<?php
2
3
namespace OAuth;
4
5
use DateTime;
6
7
/**
8
* @Entity(repositoryClass="OAuth\Repository\AccessTokenRepository")
9
* @Table(name="AccessToken",uniqueConstraints={@UniqueConstraint(name="token_idx", columns={"token"})})
10
*/
11 View Code Duplication
class AccessToken
0 ignored issues
show
Duplication introduced by
This class seems to be duplicated in your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
12
{
13
    /**
14
     * @var integer
15
     * @Id
16
     * @Column(type="integer", length=11)
17
     * @GeneratedValue
18
     */
19
    private $id;
20
21
    /**
22
     * @var string
23
     * @Column(type="string",length=40)
24
     */
25
    private $token;
26
27
    /**
28
     * @var int $clientId
29
     * @Column(type="integer", length=11)
30
     */
31
    private $clientId;
32
33
    /**
34
     * @var int $userId
35
     * @Column(type="integer", length=11, nullable=true)
36
     */
37
    private $userId;
38
39
    /**
40
     * @var DateTime
41
     * @Column(type="datetime")
42
     */
43
    private $expires;
44
45
    /**
46
     * @var string
47
     * @Column(type="string", length=50, nullable=true)
48
     */
49
    private $scope;
50
51
    /**
52
     * @var Client
53
     * @ManyToOne(targetEntity="OAuth\Client")
54
     * @JoinColumn(name="clientId", referencedColumnName="id")
55
     */
56
    private $client;
57
58
    /**
59
     * @var User
60
     * @ManyToOne(targetEntity="OAuth\User")
61
     * @JoinColumn(name="userId", referencedColumnName="id")
62
     */
63
    private $user;
64
65
    /**
66
     * Get id
67
     *
68
     * @return integer
69
     */
70
    public function getId()
71
    {
72
        return $this->id;
73
    }
74
75
    /**
76
     * Set token
77
     *
78
     * @param string $token
79
     * @return AccessToken
80
     */
81
    public function setToken($token)
82
    {
83
        $this->token = $token;
84
        return $this;
85
    }
86
87
    /**
88
     * Get token
89
     *
90
     * @return string
91
     */
92
    public function getToken()
93
    {
94
        return $this->token;
95
    }
96
97
    /**
98
     * Set client_id
99
     *
100
     * @param int $clientId
101
     * @return AccessToken
102
     */
103
    public function setClientId($clientId)
104
    {
105
        $this->clientId = $clientId;
106
        return $this;
107
    }
108
109
    /**
110
     * Get client_id
111
     *
112
     * @return int
113
     */
114
    public function getClientId()
115
    {
116
        return $this->clientId;
117
    }
118
119
    /**
120
     * Set user_id
121
     *
122
     * @param int $userId
123
     * @return AccessToken
124
     */
125
    public function setUserId($userId)
126
    {
127
        $this->userId = $userId;
128
        return $this;
129
    }
130
131
    /**
132
     * Get user_identifier
133
     *
134
     * @return int
135
     */
136
    public function getUserId()
137
    {
138
        return $this->userId;
139
    }
140
141
    /**
142
     * Set expires
143
     *
144
     * @param DateTime $expires
145
     * @return AccessToken
146
     */
147
    public function setExpires($expires)
148
    {
149
        $this->expires = $expires;
150
        return $this;
151
    }
152
153
    /**
154
     * Get expires
155
     *
156
     * @return DateTime
157
     */
158
    public function getExpires()
159
    {
160
        return $this->expires;
161
    }
162
163
    /**
164
     * Set scope
165
     *
166
     * @param string $scope
167
     * @return AccessToken
168
     */
169
    public function setScope($scope)
170
    {
171
        $this->scope = $scope;
172
        return $this;
173
    }
174
175
    /**
176
     * Get scope
177
     *
178
     * @return string
179
     */
180
    public function getScope()
181
    {
182
        return $this->scope;
183
    }
184
185
    /**
186
     * Set client
187
     *
188
     * @param Client $client
189
     * @return AccessToken
190
     */
191
    public function setClient(Client $client = null)
192
    {
193
        $this->client = $client;
194
        return $this;
195
    }
196
197
    /**
198
     * Get client
199
     *
200
     * @return Client
201
     */
202
    public function getClient()
203
    {
204
        return $this->client;
205
    }
206
207
    /**
208
     * @param $params
209
     * @return AccessToken
210
     */
211
    public static function fromArray($params)
212
    {
213
        $token = new self();
214
        foreach ($params as $property => $value) {
215
            $token->$property = $value;
216
        }
217
        return $token;
218
    }
219
220
    /**
221
     * Set user
222
     *
223
     * @param User $user
224
     * @return AccessToken
225
     */
226
    public function setUser(User $user = null)
227
    {
228
        $this->user = $user;
229
        return $this;
230
    }
231
232
    /**
233
     * Get user
234
     *
235
     * @return User
236
     */
237
    public function getUser()
238
    {
239
        return $this->user;
240
    }
241
242
    /**
243
     * @return array
244
     */
245
    public function toArray()
246
    {
247
        return [
248
            'token' => $this->token,
249
            'client_id' => $this->clientId,
250
            'user_id' => $this->userId,
251
            'expires' => $this->expires,
252
            'scope' => $this->scope,
253
        ];
254
    }
255
}