Code Coverage |
||||||||||
Lines |
Functions and Methods |
Classes and Traits |
||||||||
Total | |
0.00% |
0 / 28 |
|
0.00% |
0 / 18 |
CRAP | |
0.00% |
0 / 1 |
LoginToken | |
0.00% |
0 / 28 |
|
0.00% |
0 / 18 |
380 | |
0.00% |
0 / 1 |
__construct | |
0.00% |
0 / 1 |
|
0.00% |
0 / 1 |
2 | |||
getId | |
0.00% |
0 / 1 |
|
0.00% |
0 / 1 |
2 | |||
setUser | |
0.00% |
0 / 2 |
|
0.00% |
0 / 1 |
2 | |||
getUser | |
0.00% |
0 / 3 |
|
0.00% |
0 / 1 |
6 | |||
setToken | |
0.00% |
0 / 2 |
|
0.00% |
0 / 1 |
2 | |||
getToken | |
0.00% |
0 / 1 |
|
0.00% |
0 / 1 |
2 | |||
setSeries | |
0.00% |
0 / 2 |
|
0.00% |
0 / 1 |
2 | |||
getSeries | |
0.00% |
0 / 1 |
|
0.00% |
0 / 1 |
2 | |||
setLastLogin | |
0.00% |
0 / 2 |
|
0.00% |
0 / 1 |
2 | |||
getLastLogin | |
0.00% |
0 / 1 |
|
0.00% |
0 / 1 |
2 | |||
setBrowser | |
0.00% |
0 / 2 |
|
0.00% |
0 / 1 |
2 | |||
getBrowser | |
0.00% |
0 / 1 |
|
0.00% |
0 / 1 |
2 | |||
setPlatform | |
0.00% |
0 / 2 |
|
0.00% |
0 / 1 |
2 | |||
getPlatform | |
0.00% |
0 / 1 |
|
0.00% |
0 / 1 |
2 | |||
setExpires | |
0.00% |
0 / 2 |
|
0.00% |
0 / 1 |
2 | |||
getExpires | |
0.00% |
0 / 1 |
|
0.00% |
0 / 1 |
2 | |||
setLastSessionId | |
0.00% |
0 / 2 |
|
0.00% |
0 / 1 |
2 | |||
getLastSessionId | |
0.00% |
0 / 1 |
|
0.00% |
0 / 1 |
2 |
1 | <?php |
2 | |
3 | /** |
4 | * Row Definition for login_token |
5 | * |
6 | * PHP version 8 |
7 | * |
8 | * Copyright (C) The National Library of Finland 2023. |
9 | * |
10 | * This program is free software; you can redistribute it and/or modify |
11 | * it under the terms of the GNU General Public License version 2, |
12 | * as published by the Free Software Foundation. |
13 | * |
14 | * This program is distributed in the hope that it will be useful, |
15 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
16 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
17 | * GNU General Public License for more details. |
18 | * |
19 | * You should have received a copy of the GNU General Public License |
20 | * along with this program; if not, write to the Free Software |
21 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA |
22 | * |
23 | * @category VuFind |
24 | * @package Db_Row |
25 | * @author Jaro Ravila <jaro.ravila@helsinki.fi> |
26 | * @license http://opensource.org/licenses/gpl-2.0.php GNU General Public License |
27 | * @link https://vufind.org Main Site |
28 | */ |
29 | |
30 | namespace VuFind\Db\Row; |
31 | |
32 | use DateTime; |
33 | use VuFind\Db\Entity\LoginTokenEntityInterface; |
34 | use VuFind\Db\Entity\UserEntityInterface; |
35 | use VuFind\Db\Service\DbServiceAwareInterface; |
36 | use VuFind\Db\Service\DbServiceAwareTrait; |
37 | use VuFind\Db\Service\UserServiceInterface; |
38 | |
39 | /** |
40 | * Row Definition for login_token |
41 | * |
42 | * @category VuFind |
43 | * @package Db_Row |
44 | * @author Jaro Ravila <jaro.ravila@helsinki.fi> |
45 | * @license http://opensource.org/licenses/gpl-2.0.php GNU General Public License |
46 | * @link https://vufind.org Main Site |
47 | * |
48 | * @property int $id |
49 | * @property int $user_id |
50 | * @property string $token |
51 | * @property string $series |
52 | * @property string $last_login |
53 | * @property ?string $browser |
54 | * @property ?string $platform |
55 | * @property int $expires |
56 | * @property string $last_session_id |
57 | */ |
58 | class LoginToken extends RowGateway implements DbServiceAwareInterface, LoginTokenEntityInterface |
59 | { |
60 | use DbServiceAwareTrait; |
61 | |
62 | /** |
63 | * Constructor |
64 | * |
65 | * @param \Laminas\Db\Adapter\Adapter $adapter Database adapter |
66 | */ |
67 | public function __construct($adapter) |
68 | { |
69 | parent::__construct('id', 'login_token', $adapter); |
70 | } |
71 | |
72 | /** |
73 | * Getter for ID. |
74 | * |
75 | * @return int |
76 | */ |
77 | public function getId(): int |
78 | { |
79 | return $this->id; |
80 | } |
81 | |
82 | /** |
83 | * Setter for User. |
84 | * |
85 | * @param UserEntityInterface $user User to set |
86 | * |
87 | * @return LoginTokenEntityInterface |
88 | */ |
89 | public function setUser(UserEntityInterface $user): LoginTokenEntityInterface |
90 | { |
91 | $this->user_id = $user->getId(); |
92 | return $this; |
93 | } |
94 | |
95 | /** |
96 | * User getter (only null if entity has not been populated yet). |
97 | * |
98 | * @return ?UserEntityInterface |
99 | */ |
100 | public function getUser(): ?UserEntityInterface |
101 | { |
102 | return $this->user_id |
103 | ? $this->getDbServiceManager()->get(UserServiceInterface::class)->getUserById($this->user_id) |
104 | : null; |
105 | } |
106 | |
107 | /** |
108 | * Set token string. |
109 | * |
110 | * @param string $token Token |
111 | * |
112 | * @return LoginTokenEntityInterface |
113 | */ |
114 | public function setToken(string $token): LoginTokenEntityInterface |
115 | { |
116 | $this->token = $token; |
117 | return $this; |
118 | } |
119 | |
120 | /** |
121 | * Get token string. |
122 | * |
123 | * @return string |
124 | */ |
125 | public function getToken(): string |
126 | { |
127 | return $this->token; |
128 | } |
129 | |
130 | /** |
131 | * Set series string. |
132 | * |
133 | * @param string $series Series |
134 | * |
135 | * @return LoginTokenEntityInterface |
136 | */ |
137 | public function setSeries(string $series): LoginTokenEntityInterface |
138 | { |
139 | $this->series = $series; |
140 | return $this; |
141 | } |
142 | |
143 | /** |
144 | * Get series string. |
145 | * |
146 | * @return string |
147 | */ |
148 | public function getSeries(): string |
149 | { |
150 | return $this->series; |
151 | } |
152 | |
153 | /** |
154 | * Set last login date/time. |
155 | * |
156 | * @param DateTime $dateTime Last login date/time |
157 | * |
158 | * @return LoginTokenEntityInterface |
159 | */ |
160 | public function setLastLogin(DateTime $dateTime): LoginTokenEntityInterface |
161 | { |
162 | $this->last_login = $dateTime->format('Y-m-d H:i:s'); |
163 | return $this; |
164 | } |
165 | |
166 | /** |
167 | * Get last login date/time. |
168 | * |
169 | * @return DateTime |
170 | */ |
171 | public function getLastLogin(): DateTime |
172 | { |
173 | return DateTime::createFromFormat('Y-m-d H:i:s', $this->last_login); |
174 | } |
175 | |
176 | /** |
177 | * Set browser details (or null for none). |
178 | * |
179 | * @param ?string $browser Browser details (or null for none) |
180 | * |
181 | * @return LoginTokenEntityInterface |
182 | */ |
183 | public function setBrowser(?string $browser): LoginTokenEntityInterface |
184 | { |
185 | $this->browser = $browser; |
186 | return $this; |
187 | } |
188 | |
189 | /** |
190 | * Get browser details (or null for none). |
191 | * |
192 | * @return ?string |
193 | */ |
194 | public function getBrowser(): ?string |
195 | { |
196 | return $this->browser; |
197 | } |
198 | |
199 | /** |
200 | * Set platform details (or null for none). |
201 | * |
202 | * @param ?string $platform Platform details (or null for none) |
203 | * |
204 | * @return LoginTokenEntityInterface |
205 | */ |
206 | public function setPlatform(?string $platform): LoginTokenEntityInterface |
207 | { |
208 | $this->platform = $platform; |
209 | return $this; |
210 | } |
211 | |
212 | /** |
213 | * Get platform details (or null for none). |
214 | * |
215 | * @return ?string |
216 | */ |
217 | public function getPlatform(): ?string |
218 | { |
219 | return $this->platform; |
220 | } |
221 | |
222 | /** |
223 | * Set expiration timestamp. |
224 | * |
225 | * @param int $expires Expiration timestamp |
226 | * |
227 | * @return LoginTokenEntityInterface |
228 | */ |
229 | public function setExpires(int $expires): LoginTokenEntityInterface |
230 | { |
231 | $this->expires = $expires; |
232 | return $this; |
233 | } |
234 | |
235 | /** |
236 | * Get expiration timestamp. |
237 | * |
238 | * @return int |
239 | */ |
240 | public function getExpires(): int |
241 | { |
242 | return $this->expires; |
243 | } |
244 | |
245 | /** |
246 | * Set last session ID (or null for none). |
247 | * |
248 | * @param ?string $sid Last session ID (or null for none) |
249 | * |
250 | * @return LoginTokenEntityInterface |
251 | */ |
252 | public function setLastSessionId(?string $sid): LoginTokenEntityInterface |
253 | { |
254 | $this->last_session_id = $sid; |
255 | return $this; |
256 | } |
257 | |
258 | /** |
259 | * Get last session ID (or null for none). |
260 | * |
261 | * @return ?string |
262 | */ |
263 | public function getLastSessionId(): ?string |
264 | { |
265 | return $this->last_session_id; |
266 | } |
267 | } |