Code Coverage |
||||||||||
Lines |
Functions and Methods |
Classes and Traits |
||||||||
Total | |
4.00% |
1 / 25 |
|
8.33% |
1 / 12 |
CRAP | |
0.00% |
0 / 1 |
ResourceTags | |
4.00% |
1 / 25 |
|
8.33% |
1 / 12 |
242.49 | |
0.00% |
0 / 1 |
__construct | |
100.00% |
1 / 1 |
|
100.00% |
1 / 1 |
1 | |||
getId | |
0.00% |
0 / 1 |
|
0.00% |
0 / 1 |
2 | |||
getResource | |
0.00% |
0 / 3 |
|
0.00% |
0 / 1 |
6 | |||
setResource | |
0.00% |
0 / 2 |
|
0.00% |
0 / 1 |
2 | |||
getTag | |
0.00% |
0 / 3 |
|
0.00% |
0 / 1 |
6 | |||
setTag | |
0.00% |
0 / 2 |
|
0.00% |
0 / 1 |
2 | |||
getUserList | |
0.00% |
0 / 3 |
|
0.00% |
0 / 1 |
6 | |||
setUserList | |
0.00% |
0 / 2 |
|
0.00% |
0 / 1 |
2 | |||
getUser | |
0.00% |
0 / 3 |
|
0.00% |
0 / 1 |
6 | |||
setUser | |
0.00% |
0 / 2 |
|
0.00% |
0 / 1 |
2 | |||
getPosted | |
0.00% |
0 / 1 |
|
0.00% |
0 / 1 |
2 | |||
setPosted | |
0.00% |
0 / 2 |
|
0.00% |
0 / 1 |
2 |
1 | <?php |
2 | |
3 | /** |
4 | * Row Definition for resource_tags |
5 | * |
6 | * PHP version 8 |
7 | * |
8 | * Copyright (C) Villanova University 2010. |
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 Demian Katz <demian.katz@villanova.edu> |
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\ResourceEntityInterface; |
34 | use VuFind\Db\Entity\ResourceTagsEntityInterface; |
35 | use VuFind\Db\Entity\TagsEntityInterface; |
36 | use VuFind\Db\Entity\UserEntityInterface; |
37 | use VuFind\Db\Entity\UserListEntityInterface; |
38 | use VuFind\Db\Service\DbServiceAwareInterface; |
39 | use VuFind\Db\Service\DbServiceAwareTrait; |
40 | use VuFind\Db\Service\ResourceServiceInterface; |
41 | use VuFind\Db\Service\TagServiceInterface; |
42 | use VuFind\Db\Service\UserListServiceInterface; |
43 | use VuFind\Db\Service\UserServiceInterface; |
44 | |
45 | /** |
46 | * Row Definition for resource_tags |
47 | * |
48 | * @category VuFind |
49 | * @package Db_Row |
50 | * @author Demian Katz <demian.katz@villanova.edu> |
51 | * @license http://opensource.org/licenses/gpl-2.0.php GNU General Public License |
52 | * @link https://vufind.org Main Site |
53 | * |
54 | * @property int $id |
55 | * @property int $resource_id |
56 | * @property int $tag_id |
57 | * @property int $list_id |
58 | * @property int $user_id |
59 | * @property string $posted |
60 | */ |
61 | class ResourceTags extends RowGateway implements |
62 | \VuFind\Db\Entity\ResourceTagsEntityInterface, |
63 | \VuFind\Db\Table\DbTableAwareInterface, |
64 | DbServiceAwareInterface |
65 | { |
66 | use \VuFind\Db\Table\DbTableAwareTrait; |
67 | use DbServiceAwareTrait; |
68 | |
69 | /** |
70 | * Constructor |
71 | * |
72 | * @param \Laminas\Db\Adapter\Adapter $adapter Database adapter |
73 | */ |
74 | public function __construct($adapter) |
75 | { |
76 | parent::__construct('id', 'resource_tags', $adapter); |
77 | } |
78 | |
79 | /** |
80 | * Get identifier (returns null for an uninitialized or non-persisted object). |
81 | * |
82 | * @return ?int |
83 | */ |
84 | public function getId(): ?int |
85 | { |
86 | return $this->id ?? null; |
87 | } |
88 | |
89 | /** |
90 | * Get resource. |
91 | * |
92 | * @return ?ResourceEntityInterface |
93 | */ |
94 | public function getResource(): ?ResourceEntityInterface |
95 | { |
96 | return $this->resource_id |
97 | ? $this->getDbServiceManager()->get(ResourceServiceInterface::class)->getResourceById($this->resource_id) |
98 | : null; |
99 | } |
100 | |
101 | /** |
102 | * Set resource. |
103 | * |
104 | * @param ?ResourceEntityInterface $resource Resource |
105 | * |
106 | * @return ResourceTagsEntityInterface |
107 | */ |
108 | public function setResource(?ResourceEntityInterface $resource): ResourceTagsEntityInterface |
109 | { |
110 | $this->resource_id = $resource?->getId(); |
111 | return $this; |
112 | } |
113 | |
114 | /** |
115 | * Get tag. |
116 | * |
117 | * @return TagsEntityInterface |
118 | */ |
119 | public function getTag(): TagsEntityInterface |
120 | { |
121 | return $this->tag_id |
122 | ? $this->getDbServiceManager()->get(TagServiceInterface::class)->getTagById($this->tag_id) |
123 | : null; |
124 | } |
125 | |
126 | /** |
127 | * Set tag. |
128 | * |
129 | * @param TagsEntityInterface $tag Tag |
130 | * |
131 | * @return ResourceTagsEntityInterface |
132 | */ |
133 | public function setTag(TagsEntityInterface $tag): ResourceTagsEntityInterface |
134 | { |
135 | $this->tag_id = $tag->getId(); |
136 | return $this; |
137 | } |
138 | |
139 | /** |
140 | * Get user list. |
141 | * |
142 | * @return ?UserListEntityInterface |
143 | */ |
144 | public function getUserList(): ?UserListEntityInterface |
145 | { |
146 | return $this->list_id |
147 | ? $this->getDbServiceManager()->get(UserListServiceInterface::class)->getUserListById($this->list_id) |
148 | : null; |
149 | } |
150 | |
151 | /** |
152 | * Set user list. |
153 | * |
154 | * @param ?UserListEntityInterface $list User list |
155 | * |
156 | * @return ResourceTagsEntityInterface |
157 | */ |
158 | public function setUserList(?UserListEntityInterface $list): ResourceTagsEntityInterface |
159 | { |
160 | $this->list_id = $list?->getId(); |
161 | return $this; |
162 | } |
163 | |
164 | /** |
165 | * Get user. |
166 | * |
167 | * @return ?UserEntityInterface |
168 | */ |
169 | public function getUser(): ?UserEntityInterface |
170 | { |
171 | return $this->user_id |
172 | ? $this->getDbServiceManager()->get(UserServiceInterface::class)->getUserById($this->user_id) |
173 | : null; |
174 | } |
175 | |
176 | /** |
177 | * Set user. |
178 | * |
179 | * @param ?UserEntityInterface $user User |
180 | * |
181 | * @return ResourceTagsEntityInterface |
182 | */ |
183 | public function setUser(?UserEntityInterface $user): ResourceTagsEntityInterface |
184 | { |
185 | $this->user_id = $user?->getId(); |
186 | return $this; |
187 | } |
188 | |
189 | /** |
190 | * Get created date. |
191 | * |
192 | * @return DateTime |
193 | */ |
194 | public function getPosted(): DateTime |
195 | { |
196 | return DateTime::createFromFormat('Y-m-d H:i:s', $this->posted); |
197 | } |
198 | |
199 | /** |
200 | * Set created date. |
201 | * |
202 | * @param DateTime $dateTime Created date |
203 | * |
204 | * @return ResourceTagsEntityInterface |
205 | */ |
206 | public function setPosted(DateTime $dateTime): ResourceTagsEntityInterface |
207 | { |
208 | $this->posted = $dateTime->format('Y-m-d H:i:s'); |
209 | return $this; |
210 | } |
211 | } |