Code Duplication    Length = 245-245 lines in 2 locations

src/Entity/OAuth/AccessToken.php 1 location

@@ 11-255 (lines=245) @@
8
* @Entity(repositoryClass="OAuth\Repository\AccessTokenRepository")
9
* @Table(name="AccessToken",uniqueConstraints={@UniqueConstraint(name="token_idx", columns={"token"})})
10
*/
11
class AccessToken
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
}

src/Entity/OAuth/RefreshToken.php 1 location

@@ 11-255 (lines=245) @@
8
 * @Entity(repositoryClass="OAuth\Repository\RefreshTokenRepository")
9
 * @Table(name="RefreshToken",uniqueConstraints={@UniqueConstraint(name="refresh_token_idx", columns={"refreshToken"})})
10
 */
11
class RefreshToken
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 $refreshToken;
26
27
    /**
28
     * @var int
29
     * @Column(type="integer",length=11)
30
     */
31
    private $clientId;
32
33
    /**
34
     * @var int
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)
48
     */
49
    private $scope;
50
51
    /**
52
     * @var Client
53
     * @ManyToOne(targetEntity="OAuth\Client")
54
     * @JoinColumn(name="client", referencedColumnName="id")
55
     */
56
    private $client;
57
58
    /**
59
     * @var User
60
     * @ManyToOne(targetEntity="OAuth\User")
61
     * @JoinColumn(name="user", 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 refresh_token
77
     *
78
     * @param string $refresh_token
79
     * @return RefreshToken
80
     */
81
    public function setRefreshToken($refresh_token)
82
    {
83
        $this->refresh_token = $refresh_token;
84
        return $this;
85
    }
86
87
    /**
88
     * Get refresh_token
89
     *
90
     * @return string
91
     */
92
    public function getRefreshToken()
93
    {
94
        return $this->refreshToken;
95
    }
96
97
    /**
98
     * Set client_id
99
     *
100
     * @param int $clientId
101
     * @return RefreshToken
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 RefreshToken
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 RefreshToken
146
     */
147
    public function setExpires(DateTime $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 RefreshToken
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 RefreshToken
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
     * Set user
209
     *
210
     * @param User $user
211
     * @return RefreshToken
212
     */
213
    public function setUser(User $user = null)
214
    {
215
        $this->user = $user;
216
        return $this;
217
    }
218
219
    /**
220
     * Get user
221
     *
222
     * @return User
223
     */
224
    public function getUser()
225
    {
226
        return $this->user;
227
    }
228
229
    /**
230
     * @return array
231
     */
232
    public function toArray()
233
    {
234
        return [
235
            'refresh_token' => $this->refreshToken,
236
            'client_id' => $this->clientId,
237
            'user_id' => $this->userId,
238
            'expires' => $this->expires,
239
            'scope' => $this->scope,
240
        ];
241
    }
242
243
    /**
244
     * @param $params
245
     * @return RefreshToken
246
     */
247
    public static function fromArray($params)
248
    {
249
        $token = new self();
250
        foreach ($params as $property => $value) {
251
            $token->$property = $value;
252
        }
253
        return $token;
254
    }
255
}