User::getAccessToken()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 3
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
cc 1
eloc 1
nc 1
nop 0
dl 0
loc 3
rs 10
c 1
b 0
f 0
1
<?php
2
3
namespace App\Entity;
4
5
use DateTime;
6
use Doctrine\ORM\Mapping as ORM;
7
use Symfony\Component\Security\Core\User\PasswordAuthenticatedUserInterface;
8
use Symfony\Component\Security\Core\User\UserInterface;
9
10
/**
11
 * @ORM\Entity(repositoryClass="App\Repository\UserRepository")
12
 * @ORM\Table(name="`user`")
13
 */
14
class User implements UserInterface, PasswordAuthenticatedUserInterface
15
{
16
    /**
17
     * @ORM\Id
18
     * @ORM\GeneratedValue
19
     * @ORM\Column(type="integer")
20
     */
21
    private int $id;
22
23
    /**
24
     * @ORM\Column(type="string", length=180, unique=true)
25
     */
26
    private string $email;
27
28
    /**
29
     * @ORM\Column(type="string", unique=true)
30
     */
31
    private string $googleId;
32
33
    /**
34
     * @ORM\Column(type="string")
35
     */
36
    private string $refreshToken;
37
38
    /**
39
     * @ORM\Column(type="string")
40
     */
41
    private string $accessToken;
42
43
    /**
44
     * @ORM\Column(type="datetime")
45
     */
46
    private DateTime $accessTokenCreatedAt;
47
48
    /**
49
     * @ORM\Column(type="datetime")
50
     */
51
    private DateTime $accessTokenExpiresAt;
52
53
    /**
54
     * @ORM\Column(type="string", nullable=true)
55
     */
56
    private ?string $avatar;
57
58
    /**
59
     * @ORM\Column(type="json")
60
     */
61
    private array $propertySearchSettings = [];
62
63
    /**
64
     * @ORM\Column(type="datetime", nullable=true)
65
     */
66
    private ?DateTime $revokedAt;
67
68
    /**
69
     * @ORM\Column(type="datetime")
70
     */
71
    private DateTime $createdAt;
72
73
    /**
74
     * @ORM\Column(type="json")
75
     */
76
    private array $roles = [];
77
78
    public function __construct()
79
    {
80
        $this->createdAt = new DateTime();
81
    }
82
83
    public function getId(): ?int
84
    {
85
        return $this->id;
86
    }
87
88
    public function getEmail(): ?string
89
    {
90
        return $this->email;
91
    }
92
93
    public function setEmail(string $email): self
94
    {
95
        $this->email = $email;
96
97
        return $this;
98
    }
99
100
    public function getGoogleId(): string
101
    {
102
        return $this->googleId;
103
    }
104
105
    public function setGoogleId(string $googleId): User
106
    {
107
        $this->googleId = $googleId;
108
109
        return $this;
110
    }
111
112
    public function getRefreshToken(): string
113
    {
114
        return $this->refreshToken;
115
    }
116
117
    public function setRefreshToken(string $refreshToken): User
118
    {
119
        $this->refreshToken = $refreshToken;
120
121
        return $this;
122
    }
123
124
    public function getAccessToken(): string
125
    {
126
        return $this->accessToken;
127
    }
128
129
    public function setAccessToken(string $accessToken): User
130
    {
131
        $this->accessToken = $accessToken;
132
133
        return $this;
134
    }
135
136
    public function getAccessTokenCreatedAt(): DateTime
137
    {
138
        return $this->accessTokenCreatedAt;
139
    }
140
141
    public function setAccessTokenCreatedAt(DateTime $accessTokenCreatedAt): User
142
    {
143
        $this->accessTokenCreatedAt = $accessTokenCreatedAt;
144
145
        return $this;
146
    }
147
148
    public function getAccessTokenExpiresAt(): DateTime
149
    {
150
        return $this->accessTokenExpiresAt;
151
    }
152
153
    public function setAccessTokenExpiresAt(DateTime $accessTokenExpiresAt): User
154
    {
155
        $this->accessTokenExpiresAt = $accessTokenExpiresAt;
156
157
        return $this;
158
    }
159
160
    public function getAvatar(): ?string
161
    {
162
        return $this->avatar;
163
    }
164
165
    public function setAvatar(?string $avatar): User
166
    {
167
        $this->avatar = $avatar;
168
169
        return $this;
170
    }
171
172
    public function getPropertySearchSettings(): array
173
    {
174
        return $this->propertySearchSettings;
175
    }
176
177
    public function setPropertySearchSettings(array $propertySearchSettings): User
178
    {
179
        $this->propertySearchSettings = $propertySearchSettings;
180
181
        return $this;
182
    }
183
184
    public function getRevokedAt(): ?DateTime
185
    {
186
        return $this->revokedAt;
187
    }
188
189
    public function setRevokedAt(?DateTime $revokedAt): User
190
    {
191
        $this->revokedAt = $revokedAt;
192
193
        return $this;
194
    }
195
196
    public function getCreatedAt(): DateTime
197
    {
198
        return $this->createdAt;
199
    }
200
201
    public function setCreatedAt(DateTime $createdAt): User
202
    {
203
        $this->createdAt = $createdAt;
204
205
        return $this;
206
    }
207
208
    public function isRevoked(): bool
209
    {
210
        return null !== $this->revokedAt;
211
    }
212
213
    /**
214
     * {@inheritDoc}
215
     */
216
    public function getUsername(): string
217
    {
218
        return $this->email;
219
    }
220
221
    /**
222
     * {@inheritDoc}
223
     */
224
    public function getRoles(): array
225
    {
226
        $roles = $this->roles;
227
        // guarantee every user at least has ROLE_USER
228
        $roles[] = 'ROLE_USER';
229
230
        return array_unique($roles);
231
    }
232
233
    /**
234
     * @param string[] $roles
235
     */
236
    public function setRoles(array $roles): self
237
    {
238
        $this->roles = $roles;
239
240
        return $this;
241
    }
242
243
    /**
244
     * {@inheritDoc}
245
     */
246
    public function getPassword(): ?string
247
    {
248
        return null;
249
    }
250
251
    /**
252
     * {@inheritDoc}
253
     */
254
    public function getSalt()
255
    {
256
    }
257
258
    /**
259
     * {@inheritDoc}
260
     */
261
    public function eraseCredentials(): void
262
    {
263
    }
264
265
    /**
266
     * {@inheritDoc}
267
     */
268
    public function getUserIdentifier(): string
269
    {
270
        return $this->email;
271
    }
272
}
273