Code Coverage |
||||||||||
Lines |
Functions and Methods |
Classes and Traits |
||||||||
Total | |
0.00% |
0 / 26 |
|
0.00% |
0 / 18 |
CRAP | |
0.00% |
0 / 1 |
UserCard | |
0.00% |
0 / 26 |
|
0.00% |
0 / 18 |
342 | |
0.00% |
0 / 1 |
__construct | |
0.00% |
0 / 1 |
|
0.00% |
0 / 1 |
2 | |||
getId | |
0.00% |
0 / 1 |
|
0.00% |
0 / 1 |
2 | |||
setCardName | |
0.00% |
0 / 2 |
|
0.00% |
0 / 1 |
2 | |||
getCardName | |
0.00% |
0 / 1 |
|
0.00% |
0 / 1 |
2 | |||
setCatUsername | |
0.00% |
0 / 2 |
|
0.00% |
0 / 1 |
2 | |||
getCatUsername | |
0.00% |
0 / 1 |
|
0.00% |
0 / 1 |
2 | |||
setRawCatPassword | |
0.00% |
0 / 2 |
|
0.00% |
0 / 1 |
2 | |||
getRawCatPassword | |
0.00% |
0 / 1 |
|
0.00% |
0 / 1 |
2 | |||
setCatPassEnc | |
0.00% |
0 / 2 |
|
0.00% |
0 / 1 |
2 | |||
getCatPassEnc | |
0.00% |
0 / 1 |
|
0.00% |
0 / 1 |
2 | |||
setHomeLibrary | |
0.00% |
0 / 2 |
|
0.00% |
0 / 1 |
2 | |||
getHomeLibrary | |
0.00% |
0 / 1 |
|
0.00% |
0 / 1 |
2 | |||
setCreated | |
0.00% |
0 / 2 |
|
0.00% |
0 / 1 |
2 | |||
getCreated | |
0.00% |
0 / 1 |
|
0.00% |
0 / 1 |
2 | |||
setSaved | |
0.00% |
0 / 2 |
|
0.00% |
0 / 1 |
2 | |||
getSaved | |
0.00% |
0 / 1 |
|
0.00% |
0 / 1 |
2 | |||
setUser | |
0.00% |
0 / 2 |
|
0.00% |
0 / 1 |
2 | |||
getUser | |
0.00% |
0 / 1 |
|
0.00% |
0 / 1 |
2 |
1 | <?php |
2 | |
3 | /** |
4 | * Row Definition for user_card |
5 | * |
6 | * PHP version 8 |
7 | * |
8 | * Copyright (C) The National Library of Finland 2015. |
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 Ere Maijala <ere.maijala@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\UserCardEntityInterface; |
34 | use VuFind\Db\Entity\UserEntityInterface; |
35 | use VuFind\Db\Service\DbServiceAwareInterface; |
36 | |
37 | /** |
38 | * Row Definition for user_card |
39 | * |
40 | * @category VuFind |
41 | * @package Db_Row |
42 | * @author Ere Maijala <ere.maijala@helsinki.fi> |
43 | * @license http://opensource.org/licenses/gpl-2.0.php GNU General Public License |
44 | * @link https://vufind.org Main Site |
45 | * |
46 | * @property int $id |
47 | * @property int $user_id |
48 | * @property string $card_name |
49 | * @property string $cat_username |
50 | * @property ?string $cat_password |
51 | * @property ?string $cat_pass_enc |
52 | * @property ?string $home_library |
53 | * @property string $created |
54 | * @property string $saved |
55 | */ |
56 | class UserCard extends RowGateway implements DbServiceAwareInterface, UserCardEntityInterface |
57 | { |
58 | use \VuFind\Db\Service\DbServiceAwareTrait; |
59 | |
60 | /** |
61 | * Constructor |
62 | * |
63 | * @param \Laminas\Db\Adapter\Adapter $adapter Database adapter |
64 | */ |
65 | public function __construct($adapter) |
66 | { |
67 | parent::__construct('id', 'user_card', $adapter); |
68 | } |
69 | |
70 | /** |
71 | * ID getter (returns null if the entity has not been saved/populated yet) |
72 | * |
73 | * @return ?int |
74 | */ |
75 | public function getId(): ?int |
76 | { |
77 | return $this->id ?? null; |
78 | } |
79 | |
80 | /** |
81 | * Card name setter |
82 | * |
83 | * @param string $cardName User card name. |
84 | * |
85 | * @return UserCardEntityInterface |
86 | */ |
87 | public function setCardName(string $cardName): UserCardEntityInterface |
88 | { |
89 | $this->card_name = $cardName; |
90 | return $this; |
91 | } |
92 | |
93 | /** |
94 | * Get user card name. |
95 | * |
96 | * @return string |
97 | */ |
98 | public function getCardName(): string |
99 | { |
100 | return $this->card_name; |
101 | } |
102 | |
103 | /** |
104 | * Catalog username setter |
105 | * |
106 | * @param string $catUsername Catalog username |
107 | * |
108 | * @return UserCardEntityInterface |
109 | */ |
110 | public function setCatUsername(string $catUsername): UserCardEntityInterface |
111 | { |
112 | $this->cat_username = $catUsername; |
113 | return $this; |
114 | } |
115 | |
116 | /** |
117 | * Get catalog username. |
118 | * |
119 | * @return string |
120 | */ |
121 | public function getCatUsername(): string |
122 | { |
123 | return $this->cat_username; |
124 | } |
125 | |
126 | /** |
127 | * Raw catalog password setter |
128 | * |
129 | * @param ?string $catPassword Cat password |
130 | * |
131 | * @return UserCardEntityInterface |
132 | */ |
133 | public function setRawCatPassword(?string $catPassword): UserCardEntityInterface |
134 | { |
135 | $this->cat_password = $catPassword; |
136 | return $this; |
137 | } |
138 | |
139 | /** |
140 | * Get raw catalog password. |
141 | * |
142 | * @return ?string |
143 | */ |
144 | public function getRawCatPassword(): ?string |
145 | { |
146 | return $this->cat_password; |
147 | } |
148 | |
149 | /** |
150 | * Encrypted catalog password setter |
151 | * |
152 | * @param ?string $passEnc Encrypted password |
153 | * |
154 | * @return UserCardEntityInterface |
155 | */ |
156 | public function setCatPassEnc(?string $passEnc): UserCardEntityInterface |
157 | { |
158 | $this->cat_pass_enc = $passEnc; |
159 | return $this; |
160 | } |
161 | |
162 | /** |
163 | * Get encrypted catalog password. |
164 | * |
165 | * @return ?string |
166 | */ |
167 | public function getCatPassEnc(): ?string |
168 | { |
169 | return $this->cat_pass_enc; |
170 | } |
171 | |
172 | /** |
173 | * Home library setter |
174 | * |
175 | * @param ?string $homeLibrary Home library |
176 | * |
177 | * @return UserCardEntityInterface |
178 | */ |
179 | public function setHomeLibrary(?string $homeLibrary): UserCardEntityInterface |
180 | { |
181 | $this->home_library = $homeLibrary; |
182 | return $this; |
183 | } |
184 | |
185 | /** |
186 | * Get home library. |
187 | * |
188 | * @return ?string |
189 | */ |
190 | public function getHomeLibrary(): ?string |
191 | { |
192 | return $this->home_library; |
193 | } |
194 | |
195 | /** |
196 | * Created date setter. |
197 | * |
198 | * @param DateTime $dateTime Created date |
199 | * |
200 | * @return UserCardEntityInterface |
201 | */ |
202 | public function setCreated(DateTime $dateTime): UserCardEntityInterface |
203 | { |
204 | $this->created = $dateTime->format('Y-m-d H:i:s'); |
205 | return $this; |
206 | } |
207 | |
208 | /** |
209 | * Get created date. |
210 | * |
211 | * @return DateTime |
212 | */ |
213 | public function getCreated(): DateTime |
214 | { |
215 | return DateTime::createFromFormat('Y-m-d H:i:s', $this->created); |
216 | } |
217 | |
218 | /** |
219 | * Set time the card is saved. |
220 | * |
221 | * @param DateTime $dateTime Saved date and time |
222 | * |
223 | * @return UserCardEntityInterface |
224 | */ |
225 | public function setSaved(DateTime $dateTime): UserCardEntityInterface |
226 | { |
227 | $this->saved = $dateTime->format('Y-m-d H:i:s'); |
228 | return $this; |
229 | } |
230 | |
231 | /** |
232 | * Get saved time. |
233 | * |
234 | * @return DateTime |
235 | */ |
236 | public function getSaved(): DateTime |
237 | { |
238 | return DateTime::createFromFormat('Y-m-d H:i:s', $this->saved); |
239 | } |
240 | |
241 | /** |
242 | * User setter. |
243 | * |
244 | * @param UserEntityInterface $user User that owns card |
245 | * |
246 | * @return UserCardEntityInterface |
247 | */ |
248 | public function setUser(UserEntityInterface $user): UserCardEntityInterface |
249 | { |
250 | $this->user_id = $user->getId(); |
251 | return $this; |
252 | } |
253 | |
254 | /** |
255 | * User getter |
256 | * |
257 | * @return UserEntityInterface |
258 | */ |
259 | public function getUser(): UserEntityInterface |
260 | { |
261 | return $this->getDbService(\VuFind\Db\Service\UserServiceInterface::class)->getUserById($this->user_id); |
262 | } |
263 | } |