Code Coverage
 
Lines
Functions and Methods
Classes and Traits
Total
100.00% covered (success)
100.00%
59 / 59
100.00% covered (success)
100.00%
35 / 35
CRAP
100.00% covered (success)
100.00%
1 / 1
FaqEntity
100.00% covered (success)
100.00%
59 / 59
100.00% covered (success)
100.00%
35 / 35
39
100.00% covered (success)
100.00%
1 / 1
 getId
100.00% covered (success)
100.00%
1 / 1
100.00% covered (success)
100.00%
1 / 1
1
 setId
100.00% covered (success)
100.00%
2 / 2
100.00% covered (success)
100.00%
1 / 1
1
 getLanguage
100.00% covered (success)
100.00%
1 / 1
100.00% covered (success)
100.00%
1 / 1
1
 setLanguage
100.00% covered (success)
100.00%
2 / 2
100.00% covered (success)
100.00%
1 / 1
1
 getSolutionId
100.00% covered (success)
100.00%
1 / 1
100.00% covered (success)
100.00%
1 / 1
1
 setSolutionId
100.00% covered (success)
100.00%
2 / 2
100.00% covered (success)
100.00%
1 / 1
1
 getRevisionId
100.00% covered (success)
100.00%
1 / 1
100.00% covered (success)
100.00%
1 / 1
1
 setRevisionId
100.00% covered (success)
100.00%
2 / 2
100.00% covered (success)
100.00%
1 / 1
1
 isActive
100.00% covered (success)
100.00%
1 / 1
100.00% covered (success)
100.00%
1 / 1
1
 setActive
100.00% covered (success)
100.00%
2 / 2
100.00% covered (success)
100.00%
1 / 1
1
 isSticky
100.00% covered (success)
100.00%
1 / 1
100.00% covered (success)
100.00%
1 / 1
1
 setSticky
100.00% covered (success)
100.00%
2 / 2
100.00% covered (success)
100.00%
1 / 1
1
 getKeywords
100.00% covered (success)
100.00%
1 / 1
100.00% covered (success)
100.00%
1 / 1
1
 setKeywords
100.00% covered (success)
100.00%
2 / 2
100.00% covered (success)
100.00%
1 / 1
1
 getQuestion
100.00% covered (success)
100.00%
1 / 1
100.00% covered (success)
100.00%
1 / 1
1
 setQuestion
100.00% covered (success)
100.00%
2 / 2
100.00% covered (success)
100.00%
1 / 1
1
 getAnswer
100.00% covered (success)
100.00%
1 / 1
100.00% covered (success)
100.00%
1 / 1
1
 setAnswer
100.00% covered (success)
100.00%
2 / 2
100.00% covered (success)
100.00%
1 / 1
1
 getAuthor
100.00% covered (success)
100.00%
1 / 1
100.00% covered (success)
100.00%
1 / 1
1
 setAuthor
100.00% covered (success)
100.00%
2 / 2
100.00% covered (success)
100.00%
1 / 1
1
 getEmail
100.00% covered (success)
100.00%
1 / 1
100.00% covered (success)
100.00%
1 / 1
1
 setEmail
100.00% covered (success)
100.00%
2 / 2
100.00% covered (success)
100.00%
1 / 1
1
 isComment
100.00% covered (success)
100.00%
1 / 1
100.00% covered (success)
100.00%
1 / 1
1
 setComment
100.00% covered (success)
100.00%
2 / 2
100.00% covered (success)
100.00%
1 / 1
1
 getNotes
100.00% covered (success)
100.00%
1 / 1
100.00% covered (success)
100.00%
1 / 1
1
 setNotes
100.00% covered (success)
100.00%
2 / 2
100.00% covered (success)
100.00%
1 / 1
1
 getValidFrom
100.00% covered (success)
100.00%
3 / 3
100.00% covered (success)
100.00%
1 / 1
2
 setValidFrom
100.00% covered (success)
100.00%
2 / 2
100.00% covered (success)
100.00%
1 / 1
1
 getValidTo
100.00% covered (success)
100.00%
3 / 3
100.00% covered (success)
100.00%
1 / 1
2
 setValidTo
100.00% covered (success)
100.00%
2 / 2
100.00% covered (success)
100.00%
1 / 1
1
 getCreatedDate
100.00% covered (success)
100.00%
3 / 3
100.00% covered (success)
100.00%
1 / 1
2
 setCreatedDate
100.00% covered (success)
100.00%
2 / 2
100.00% covered (success)
100.00%
1 / 1
1
 getUpdatedDate
100.00% covered (success)
100.00%
1 / 1
100.00% covered (success)
100.00%
1 / 1
1
 setUpdatedDate
100.00% covered (success)
100.00%
2 / 2
100.00% covered (success)
100.00%
1 / 1
1
 getJson
100.00% covered (success)
100.00%
2 / 2
100.00% covered (success)
100.00%
1 / 1
2
1<?php
2
3/**
4 * The FAQ entity class.
5 * This Source Code Form is subject to the terms of the Mozilla Public License,
6 * v. 2.0. If a copy of the MPL was not distributed with this file, You can
7 * obtain one at https://mozilla.org/MPL/2.0/.
8 *
9 * @package   phpMyFAQ\Entity
10 * @author    Thorsten Rinne <thorsten@phpmyfaq.de>
11 * @copyright 2020-2026 phpMyFAQ Team
12 * @license   https://www.mozilla.org/MPL/2.0/ Mozilla Public License Version 2.0
13 * @link      https://www.phpmyfaq.de
14 * @since     2020-11-01
15 */
16
17declare(strict_types=1);
18
19namespace phpMyFAQ\Entity;
20
21use DateTime;
22
23/**
24 * Class FaqEntity
25 *
26 * @package phpMyFAQ\Entity
27 */
28/* @mago-expect lint:too-many-properties - mirrors the faqdata table columns */
29class FaqEntity
30{
31    private ?int $id = null;
32
33    private ?string $language = null;
34
35    private ?int $solutionId = null;
36
37    private ?int $revisionId = null;
38
39    private ?bool $active = null;
40
41    private ?bool $sticky = null;
42
43    private ?string $keywords = null;
44
45    private ?string $question = null;
46
47    private ?string $answer = null;
48
49    private ?string $author = null;
50
51    private ?string $email = null;
52
53    private ?bool $comment = null;
54
55    private ?string $notes = null;
56
57    private ?DateTime $validFrom = null;
58
59    private ?DateTime $validTo = null;
60
61    private ?DateTime $createdDate = null;
62
63    private ?DateTime $updatedDate = null;
64
65    public function getId(): ?int
66    {
67        return $this->id;
68    }
69
70    public function setId(int $id): FaqEntity
71    {
72        $this->id = $id;
73        return $this;
74    }
75
76    public function getLanguage(): string
77    {
78        return $this->language ?? '';
79    }
80
81    public function setLanguage(string $language): FaqEntity
82    {
83        $this->language = $language;
84        return $this;
85    }
86
87    public function getSolutionId(): ?int
88    {
89        return $this->solutionId;
90    }
91
92    public function setSolutionId(int $solutionId): FaqEntity
93    {
94        $this->solutionId = $solutionId;
95        return $this;
96    }
97
98    public function getRevisionId(): int
99    {
100        return $this->revisionId ?? 0;
101    }
102
103    public function setRevisionId(int $revisionId): FaqEntity
104    {
105        $this->revisionId = $revisionId;
106        return $this;
107    }
108
109    public function isActive(): bool
110    {
111        return $this->active ?? false;
112    }
113
114    public function setActive(bool $active): FaqEntity
115    {
116        $this->active = $active;
117        return $this;
118    }
119
120    public function isSticky(): bool
121    {
122        return $this->sticky ?? false;
123    }
124
125    public function setSticky(bool $sticky): FaqEntity
126    {
127        $this->sticky = $sticky;
128        return $this;
129    }
130
131    public function getKeywords(): string
132    {
133        return $this->keywords ?? '';
134    }
135
136    public function setKeywords(string $keywords): FaqEntity
137    {
138        $this->keywords = $keywords;
139        return $this;
140    }
141
142    public function getQuestion(): string
143    {
144        return $this->question ?? '';
145    }
146
147    public function setQuestion(string $question): FaqEntity
148    {
149        $this->question = $question;
150        return $this;
151    }
152
153    public function getAnswer(): string
154    {
155        return $this->answer ?? '';
156    }
157
158    public function setAnswer(string $answer): FaqEntity
159    {
160        $this->answer = $answer;
161        return $this;
162    }
163
164    public function getAuthor(): string
165    {
166        return $this->author ?? '';
167    }
168
169    public function setAuthor(string $author): FaqEntity
170    {
171        $this->author = $author;
172        return $this;
173    }
174
175    public function getEmail(): string
176    {
177        return $this->email ?? '';
178    }
179
180    public function setEmail(string $email): FaqEntity
181    {
182        $this->email = $email;
183        return $this;
184    }
185
186    public function isComment(): bool
187    {
188        return $this->comment ?? false;
189    }
190
191    public function setComment(bool $comment): FaqEntity
192    {
193        $this->comment = $comment;
194        return $this;
195    }
196
197    public function getNotes(): string
198    {
199        return $this->notes ?? '';
200    }
201
202    public function setNotes(string $notes): FaqEntity
203    {
204        $this->notes = $notes;
205        return $this;
206    }
207
208    public function getValidFrom(): DateTime
209    {
210        if ($this->validFrom instanceof DateTime) {
211            return $this->validFrom;
212        }
213
214        return $this->validFrom = new DateTime();
215    }
216
217    public function setValidFrom(DateTime $validFrom): FaqEntity
218    {
219        $this->validFrom = $validFrom;
220        return $this;
221    }
222
223    public function getValidTo(): DateTime
224    {
225        if ($this->validTo instanceof DateTime) {
226            return $this->validTo;
227        }
228
229        return $this->validTo = new DateTime('99991231235959');
230    }
231
232    public function setValidTo(DateTime $dateTime): FaqEntity
233    {
234        $this->validTo = $dateTime;
235        return $this;
236    }
237
238    public function getCreatedDate(): DateTime
239    {
240        if ($this->createdDate instanceof DateTime) {
241            return $this->createdDate;
242        }
243
244        return $this->createdDate = new DateTime();
245    }
246
247    public function setCreatedDate(DateTime $createdDate): FaqEntity
248    {
249        $this->createdDate = $createdDate;
250        return $this;
251    }
252
253    public function getUpdatedDate(): ?DateTime
254    {
255        return $this->updatedDate ?? null;
256    }
257
258    public function setUpdatedDate(DateTime $updatedDate): FaqEntity
259    {
260        $this->updatedDate = $updatedDate;
261        return $this;
262    }
263
264    public function getJson(): string
265    {
266        $json = json_encode(get_object_vars($this));
267
268        return $json === false ? '{}' : $json;
269    }
270}