1 | <?php |
||
2 | /** |
||
3 | * sysPass |
||
4 | * |
||
5 | * @author nuxsmin |
||
6 | * @link https://syspass.org |
||
7 | * @copyright 2012-2019, Rubén Domínguez nuxsmin@$syspass.org |
||
8 | * |
||
9 | * This file is part of sysPass. |
||
10 | * |
||
11 | * sysPass is free software: you can redistribute it and/or modify |
||
12 | * it under the terms of the GNU General Public License as published by |
||
13 | * the Free Software Foundation, either version 3 of the License, or |
||
14 | * (at your option) any later version. |
||
15 | * |
||
16 | * sysPass is distributed in the hope that it will be useful, |
||
17 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
||
18 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
||
19 | * GNU General Public License for more details. |
||
20 | * |
||
21 | * You should have received a copy of the GNU General Public License |
||
22 | * along with sysPass. If not, see <http://www.gnu.org/licenses/>. |
||
23 | */ |
||
24 | |||
25 | namespace SP\DataModel; |
||
26 | |||
27 | use SP\Core\Messages\MessageInterface; |
||
28 | |||
29 | /** |
||
30 | * Class NoticeData |
||
31 | * |
||
32 | * @package SP\DataModel |
||
33 | */ |
||
34 | class NotificationData implements DataModelInterface |
||
35 | { |
||
36 | /** |
||
37 | * @var int |
||
38 | */ |
||
39 | public $id = 0; |
||
40 | /** |
||
41 | * @var string |
||
42 | */ |
||
43 | public $type; |
||
44 | /** |
||
45 | * @var string |
||
46 | */ |
||
47 | public $component; |
||
48 | /** |
||
49 | * @var string |
||
50 | */ |
||
51 | public $description; |
||
52 | /** |
||
53 | * @var int |
||
54 | */ |
||
55 | public $date = 0; |
||
56 | /** |
||
57 | * @var bool |
||
58 | */ |
||
59 | public $checked = 0; |
||
60 | /** |
||
61 | * @var int |
||
62 | */ |
||
63 | public $userId; |
||
64 | /** |
||
65 | * @var bool |
||
66 | */ |
||
67 | public $sticky = 0; |
||
68 | /** |
||
69 | * @var bool |
||
70 | */ |
||
71 | public $onlyAdmin = 0; |
||
72 | |||
73 | /** |
||
74 | * @return int |
||
75 | */ |
||
76 | public function getId() |
||
77 | { |
||
78 | return (int)$this->id; |
||
79 | } |
||
80 | |||
81 | /** |
||
82 | * @param int $id |
||
83 | */ |
||
84 | public function setId($id) |
||
85 | { |
||
86 | $this->id = (int)$id; |
||
87 | } |
||
88 | |||
89 | /** |
||
90 | * @return string |
||
91 | */ |
||
92 | public function getType() |
||
93 | { |
||
94 | return $this->type; |
||
95 | } |
||
96 | |||
97 | /** |
||
98 | * @param string $type |
||
99 | */ |
||
100 | public function setType($type) |
||
101 | { |
||
102 | $this->type = $type; |
||
103 | } |
||
104 | |||
105 | /** |
||
106 | * @return string |
||
107 | */ |
||
108 | public function getComponent() |
||
109 | { |
||
110 | return $this->component; |
||
111 | } |
||
112 | |||
113 | /** |
||
114 | * @param string $component |
||
115 | */ |
||
116 | public function setComponent($component) |
||
117 | { |
||
118 | $this->component = $component; |
||
119 | } |
||
120 | |||
121 | /** |
||
122 | * @return string |
||
123 | */ |
||
124 | public function getDescription() |
||
125 | { |
||
126 | return $this->description; |
||
127 | } |
||
128 | |||
129 | /** |
||
130 | * @param MessageInterface $message |
||
131 | * @param bool $useHtml |
||
132 | */ |
||
133 | public function setDescription(MessageInterface $message, bool $useHtml = false) |
||
134 | { |
||
135 | if ($useHtml) { |
||
136 | $this->description = $message->composeHtml(); |
||
137 | } else { |
||
138 | $this->description = $message->composeText(); |
||
139 | } |
||
140 | } |
||
141 | |||
142 | /** |
||
143 | * @return int |
||
144 | */ |
||
145 | public function getDate() |
||
146 | { |
||
147 | return (int)$this->date; |
||
148 | } |
||
149 | |||
150 | /** |
||
151 | * @param int $date |
||
152 | */ |
||
153 | public function setDate($date) |
||
154 | { |
||
155 | $this->date = (int)$date; |
||
156 | } |
||
157 | |||
158 | /** |
||
159 | * @return int |
||
160 | */ |
||
161 | public function isChecked() |
||
162 | { |
||
163 | return (int)$this->checked; |
||
164 | } |
||
165 | |||
166 | /** |
||
167 | * @param bool $checked |
||
168 | */ |
||
169 | public function setChecked($checked) |
||
170 | { |
||
171 | $this->checked = (int)$checked; |
||
0 ignored issues
–
show
|
|||
172 | } |
||
173 | |||
174 | /** |
||
175 | * @return int |
||
176 | */ |
||
177 | public function getUserId() |
||
178 | { |
||
179 | return (int)$this->userId; |
||
180 | } |
||
181 | |||
182 | /** |
||
183 | * @param int $userId |
||
184 | */ |
||
185 | public function setUserId($userId) |
||
186 | { |
||
187 | $this->userId = (int)$userId; |
||
188 | } |
||
189 | |||
190 | /** |
||
191 | * @return int |
||
192 | */ |
||
193 | public function isSticky() |
||
194 | { |
||
195 | return (int)$this->sticky; |
||
196 | } |
||
197 | |||
198 | /** |
||
199 | * @param bool $sticky |
||
200 | */ |
||
201 | public function setSticky($sticky) |
||
202 | { |
||
203 | $this->sticky = (int)$sticky; |
||
0 ignored issues
–
show
The property
$sticky was declared of type boolean , but (int)$sticky is of type integer . Maybe add a type cast?
This check looks for assignments to scalar types that may be of the wrong type. To ensure the code behaves as expected, it may be a good idea to add an explicit type cast. $answer = 42;
$correct = false;
$correct = (bool) $answer;
![]() |
|||
204 | } |
||
205 | |||
206 | /** |
||
207 | * @return int |
||
208 | */ |
||
209 | public function isOnlyAdmin() |
||
210 | { |
||
211 | return (int)$this->onlyAdmin; |
||
212 | } |
||
213 | |||
214 | /** |
||
215 | * @param bool $onlyAdmin |
||
216 | */ |
||
217 | public function setOnlyAdmin($onlyAdmin) |
||
218 | { |
||
219 | $this->onlyAdmin = (int)$onlyAdmin; |
||
0 ignored issues
–
show
The property
$onlyAdmin was declared of type boolean , but (int)$onlyAdmin is of type integer . Maybe add a type cast?
This check looks for assignments to scalar types that may be of the wrong type. To ensure the code behaves as expected, it may be a good idea to add an explicit type cast. $answer = 42;
$correct = false;
$correct = (bool) $answer;
![]() |
|||
220 | } |
||
221 | |||
222 | /** |
||
223 | * @return string |
||
224 | */ |
||
225 | public function getName() |
||
226 | { |
||
227 | return $this->component; |
||
228 | } |
||
229 | } |
This check looks for assignments to scalar types that may be of the wrong type.
To ensure the code behaves as expected, it may be a good idea to add an explicit type cast.