Code Coverage |
||||||||||
Lines |
Functions and Methods |
Classes and Traits |
||||||||
Total | |
0.00% |
0 / 33 |
|
0.00% |
0 / 20 |
CRAP | |
0.00% |
0 / 1 |
Feedback | |
0.00% |
0 / 33 |
|
0.00% |
0 / 20 |
552 | |
0.00% |
0 / 1 |
__construct | |
0.00% |
0 / 1 |
|
0.00% |
0 / 1 |
2 | |||
getId | |
0.00% |
0 / 1 |
|
0.00% |
0 / 1 |
2 | |||
setMessage | |
0.00% |
0 / 2 |
|
0.00% |
0 / 1 |
2 | |||
getMessage | |
0.00% |
0 / 1 |
|
0.00% |
0 / 1 |
2 | |||
setFormData | |
0.00% |
0 / 2 |
|
0.00% |
0 / 1 |
2 | |||
getFormData | |
0.00% |
0 / 1 |
|
0.00% |
0 / 1 |
2 | |||
setFormName | |
0.00% |
0 / 2 |
|
0.00% |
0 / 1 |
2 | |||
getFormName | |
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 | |||
setUpdated | |
0.00% |
0 / 2 |
|
0.00% |
0 / 1 |
2 | |||
getUpdated | |
0.00% |
0 / 1 |
|
0.00% |
0 / 1 |
2 | |||
setStatus | |
0.00% |
0 / 2 |
|
0.00% |
0 / 1 |
2 | |||
getStatus | |
0.00% |
0 / 1 |
|
0.00% |
0 / 1 |
2 | |||
setSiteUrl | |
0.00% |
0 / 2 |
|
0.00% |
0 / 1 |
2 | |||
getSiteUrl | |
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 | |||
setUpdatedBy | |
0.00% |
0 / 2 |
|
0.00% |
0 / 1 |
6 | |||
getUpdatedBy | |
0.00% |
0 / 3 |
|
0.00% |
0 / 1 |
6 |
1 | <?php |
2 | |
3 | /** |
4 | * Class Feedback |
5 | * |
6 | * PHP version 8 |
7 | * |
8 | * Copyright (C) Moravian Library 2022. |
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 Josef Moravec <moravec@mzk.cz> |
26 | * @license https://opensource.org/licenses/gpl-2.0.php GNU General Public License |
27 | * @link https://vufind.org Main Site |
28 | */ |
29 | |
30 | declare(strict_types=1); |
31 | |
32 | namespace VuFind\Db\Row; |
33 | |
34 | use DateTime; |
35 | use VuFind\Db\Entity\FeedbackEntityInterface; |
36 | use VuFind\Db\Entity\UserEntityInterface; |
37 | use VuFind\Db\Service\DbServiceAwareInterface; |
38 | use VuFind\Db\Service\DbServiceAwareTrait; |
39 | use VuFind\Db\Service\UserServiceInterface; |
40 | |
41 | /** |
42 | * Class Feedback |
43 | * |
44 | * @category VuFind |
45 | * @package Db_Row |
46 | * @author Josef Moravec <moravec@mzk.cz> |
47 | * @license https://opensource.org/licenses/gpl-2.0.php GNU General Public License |
48 | * @link https://vufind.org Main Site |
49 | * |
50 | * @property int $id |
51 | * @property int $user_id |
52 | * @property string $message |
53 | * @property string $form_data |
54 | * @property string $form_name |
55 | * @property string $created |
56 | * @property string $updated |
57 | * @property int $updated_by |
58 | * @property string $status |
59 | * @property string $site_url |
60 | */ |
61 | class Feedback extends RowGateway implements FeedbackEntityInterface, DbServiceAwareInterface |
62 | { |
63 | use DbServiceAwareTrait; |
64 | |
65 | /** |
66 | * Constructor |
67 | * |
68 | * @param \Laminas\Db\Adapter\Adapter $adapter Database adapter |
69 | */ |
70 | public function __construct($adapter) |
71 | { |
72 | parent::__construct('id', 'feedback', $adapter); |
73 | } |
74 | |
75 | /** |
76 | * Id getter |
77 | * |
78 | * @return int |
79 | */ |
80 | public function getId(): int |
81 | { |
82 | return $this->id; |
83 | } |
84 | |
85 | /** |
86 | * Message setter |
87 | * |
88 | * @param string $message Message |
89 | * |
90 | * @return FeedbackEntityInterface |
91 | */ |
92 | public function setMessage(string $message): FeedbackEntityInterface |
93 | { |
94 | $this->message = $message; |
95 | return $this; |
96 | } |
97 | |
98 | /** |
99 | * Message getter |
100 | * |
101 | * @return string |
102 | */ |
103 | public function getMessage(): string |
104 | { |
105 | return $this->message; |
106 | } |
107 | |
108 | /** |
109 | * Form data setter. |
110 | * |
111 | * @param array $data Form data |
112 | * |
113 | * @return FeedbackEntityInterface |
114 | */ |
115 | public function setFormData(array $data): FeedbackEntityInterface |
116 | { |
117 | $this->form_data = json_encode($data); |
118 | return $this; |
119 | } |
120 | |
121 | /** |
122 | * Form data getter |
123 | * |
124 | * @return array |
125 | */ |
126 | public function getFormData(): array |
127 | { |
128 | return json_decode($this->form_data, true); |
129 | } |
130 | |
131 | /** |
132 | * Form name setter. |
133 | * |
134 | * @param string $name Form name |
135 | * |
136 | * @return FeedbackEntityInterface |
137 | */ |
138 | public function setFormName(string $name): FeedbackEntityInterface |
139 | { |
140 | $this->form_name = $name; |
141 | return $this; |
142 | } |
143 | |
144 | /** |
145 | * Form name getter |
146 | * |
147 | * @return string |
148 | */ |
149 | public function getFormName(): string |
150 | { |
151 | return $this->form_name; |
152 | } |
153 | |
154 | /** |
155 | * Created setter. |
156 | * |
157 | * @param DateTime $dateTime Created date |
158 | * |
159 | * @return FeedbackEntityInterface |
160 | */ |
161 | public function setCreated(DateTime $dateTime): FeedbackEntityInterface |
162 | { |
163 | $this->created = $dateTime->format('Y-m-d H:i:s'); |
164 | return $this; |
165 | } |
166 | |
167 | /** |
168 | * Created getter |
169 | * |
170 | * @return DateTime |
171 | */ |
172 | public function getCreated(): DateTime |
173 | { |
174 | return DateTime::createFromFormat('Y-m-d H:i:s', $this->created); |
175 | } |
176 | |
177 | /** |
178 | * Updated setter. |
179 | * |
180 | * @param DateTime $dateTime Last update date |
181 | * |
182 | * @return FeedbackEntityInterface |
183 | */ |
184 | public function setUpdated(DateTime $dateTime): FeedbackEntityInterface |
185 | { |
186 | $this->updated = $dateTime->format('Y-m-d H:i:s'); |
187 | return $this; |
188 | } |
189 | |
190 | /** |
191 | * Updated getter |
192 | * |
193 | * @return DateTime |
194 | */ |
195 | public function getUpdated(): DateTime |
196 | { |
197 | return DateTime::createFromFormat('Y-m-d H:i:s', $this->updated); |
198 | } |
199 | |
200 | /** |
201 | * Status setter. |
202 | * |
203 | * @param string $status Status |
204 | * |
205 | * @return FeedbackEntityInterface |
206 | */ |
207 | public function setStatus(string $status): FeedbackEntityInterface |
208 | { |
209 | $this->status = $status; |
210 | return $this; |
211 | } |
212 | |
213 | /** |
214 | * Status getter |
215 | * |
216 | * @return string |
217 | */ |
218 | public function getStatus(): string |
219 | { |
220 | return $this->status; |
221 | } |
222 | |
223 | /** |
224 | * Site URL setter. |
225 | * |
226 | * @param string $url Site URL |
227 | * |
228 | * @return FeedbackEntityInterface |
229 | */ |
230 | public function setSiteUrl(string $url): FeedbackEntityInterface |
231 | { |
232 | $this->site_url = $url; |
233 | return $this; |
234 | } |
235 | |
236 | /** |
237 | * Site URL getter |
238 | * |
239 | * @return string |
240 | */ |
241 | public function getSiteUrl(): string |
242 | { |
243 | return $this->site_url; |
244 | } |
245 | |
246 | /** |
247 | * User setter. |
248 | * |
249 | * @param ?UserEntityInterface $user User that created request |
250 | * |
251 | * @return FeedbackEntityInterface |
252 | */ |
253 | public function setUser(?UserEntityInterface $user): FeedbackEntityInterface |
254 | { |
255 | $this->user_id = $user?->getId(); |
256 | return $this; |
257 | } |
258 | |
259 | /** |
260 | * User getter |
261 | * |
262 | * @return ?UserEntityInterface |
263 | */ |
264 | public function getUser(): ?UserEntityInterface |
265 | { |
266 | return $this->user_id |
267 | ? $this->getDbServiceManager()->get(UserServiceInterface::class)->getUserById($this->user_id) |
268 | : null; |
269 | } |
270 | |
271 | /** |
272 | * Updatedby setter. |
273 | * |
274 | * @param ?UserEntityInterface $user User that updated request |
275 | * |
276 | * @return FeedbackEntityInterface |
277 | */ |
278 | public function setUpdatedBy(?UserEntityInterface $user): FeedbackEntityInterface |
279 | { |
280 | $this->updated_by = $user ? $user->getId() : null; |
281 | return $this; |
282 | } |
283 | |
284 | /** |
285 | * Updatedby getter |
286 | * |
287 | * @return ?UserEntityInterface |
288 | */ |
289 | public function getUpdatedBy(): ?UserEntityInterface |
290 | { |
291 | return $this->updated_by |
292 | ? $this->getDbServiceManager()->get(UserServiceInterface::class)->getUserById($this->updated_by) |
293 | : null; |
294 | } |
295 | } |