Code Coverage |
||||||||||
Lines |
Functions and Methods |
Classes and Traits |
||||||||
Total | |
97.78% |
44 / 45 |
|
94.12% |
16 / 17 |
CRAP | |
0.00% |
0 / 1 |
QuestionRecord | |
97.78% |
44 / 45 |
|
94.12% |
16 / 17 |
17 | |
0.00% |
0 / 1 |
__construct | |
100.00% |
9 / 9 |
|
100.00% |
1 / 1 |
1 | |||
isArchived | |
100.00% |
1 / 1 |
|
100.00% |
1 / 1 |
1 | |||
setArchived | |
100.00% |
1 / 1 |
|
100.00% |
1 / 1 |
1 | |||
getQuestionText | |
100.00% |
1 / 1 |
|
100.00% |
1 / 1 |
1 | |||
getSectionHeader | |
100.00% |
1 / 1 |
|
100.00% |
1 / 1 |
1 | |||
getRevId | |
100.00% |
1 / 1 |
|
100.00% |
1 / 1 |
1 | |||
getResultUrl | |
100.00% |
1 / 1 |
|
100.00% |
1 / 1 |
1 | |||
getTimestamp | |
100.00% |
1 / 1 |
|
100.00% |
1 / 1 |
1 | |||
jsonSerialize | |
100.00% |
11 / 11 |
|
100.00% |
1 / 1 |
1 | |||
newFromArray | |
100.00% |
11 / 11 |
|
100.00% |
1 / 1 |
1 | |||
getArchiveUrl | |
100.00% |
1 / 1 |
|
100.00% |
1 / 1 |
1 | |||
setArchiveUrl | |
100.00% |
1 / 1 |
|
100.00% |
1 / 1 |
1 | |||
setQuestionText | |
100.00% |
1 / 1 |
|
100.00% |
1 / 1 |
1 | |||
isVisible | |
100.00% |
1 / 1 |
|
100.00% |
1 / 1 |
1 | |||
setVisible | |
100.00% |
1 / 1 |
|
100.00% |
1 / 1 |
1 | |||
setTimestamp | |
100.00% |
1 / 1 |
|
100.00% |
1 / 1 |
1 | |||
getContentModel | |
0.00% |
0 / 1 |
|
0.00% |
0 / 1 |
2 |
1 | <?php |
2 | |
3 | namespace GrowthExperiments\HelpPanel; |
4 | |
5 | use JsonSerializable; |
6 | |
7 | class QuestionRecord implements JsonSerializable { |
8 | private $questionText; |
9 | private $sectionHeader; |
10 | private $revId; |
11 | private $resultUrl; |
12 | private $archiveUrl; |
13 | private $timestamp; |
14 | private $isArchived; |
15 | private $isVisible; |
16 | private $contentModel; |
17 | |
18 | /** |
19 | * @param string $questionText |
20 | * @param string $sectionHeader |
21 | * @param mixed $revId |
22 | * @param int $timestamp |
23 | * @param string $resultUrl |
24 | * @param string $contentModel |
25 | * @param string $archiveUrl |
26 | * @param bool $isArchived |
27 | * @param bool $isVisible |
28 | */ |
29 | public function __construct( |
30 | $questionText, |
31 | $sectionHeader, |
32 | $revId, |
33 | $timestamp, |
34 | $resultUrl, |
35 | $contentModel, |
36 | $archiveUrl = '', |
37 | $isArchived = false, |
38 | $isVisible = true |
39 | ) { |
40 | $this->questionText = $questionText; |
41 | $this->sectionHeader = $sectionHeader; |
42 | $this->revId = $revId; |
43 | $this->resultUrl = $resultUrl; |
44 | $this->contentModel = $contentModel; |
45 | $this->timestamp = $timestamp; |
46 | $this->isArchived = $isArchived; |
47 | $this->isVisible = $isVisible; |
48 | $this->archiveUrl = $archiveUrl; |
49 | } |
50 | |
51 | /** |
52 | * @return bool |
53 | */ |
54 | public function isArchived() { |
55 | return $this->isArchived; |
56 | } |
57 | |
58 | /** |
59 | * @param bool $isArchived |
60 | */ |
61 | public function setArchived( $isArchived ) { |
62 | $this->isArchived = $isArchived; |
63 | } |
64 | |
65 | /** |
66 | * @return string |
67 | */ |
68 | public function getQuestionText() { |
69 | return $this->questionText; |
70 | } |
71 | |
72 | /** |
73 | * @return string |
74 | */ |
75 | public function getSectionHeader() { |
76 | return $this->sectionHeader; |
77 | } |
78 | |
79 | /** |
80 | * @return mixed |
81 | */ |
82 | public function getRevId() { |
83 | return $this->revId; |
84 | } |
85 | |
86 | /** |
87 | * @return string |
88 | */ |
89 | public function getResultUrl() { |
90 | return $this->resultUrl; |
91 | } |
92 | |
93 | /** |
94 | * @return int |
95 | */ |
96 | public function getTimestamp() { |
97 | return $this->timestamp; |
98 | } |
99 | |
100 | public function jsonSerialize(): array { |
101 | return [ |
102 | 'questionText' => $this->getQuestionText(), |
103 | 'sectionHeader' => $this->getSectionHeader(), |
104 | 'revId' => $this->getRevId(), |
105 | 'resultUrl' => $this->getResultUrl(), |
106 | 'contentModel' => $this->getContentModel(), |
107 | 'archiveUrl' => $this->getArchiveUrl(), |
108 | 'timestamp' => $this->getTimestamp(), |
109 | 'isArchived' => $this->isArchived(), |
110 | 'isVisible' => $this->isVisible(), |
111 | ]; |
112 | } |
113 | |
114 | /** |
115 | * @param array $content |
116 | * @return QuestionRecord |
117 | */ |
118 | public static function newFromArray( array $content ) { |
119 | return new self( |
120 | $content['questionText'] ?? '', |
121 | $content['sectionHeader'] ?? '', |
122 | $content['revId'] ?? 0, |
123 | $content['timestamp'] ?? wfTimestamp(), |
124 | $content['resultUrl'] ?? '', |
125 | $content['contentModel'] ?? CONTENT_MODEL_WIKITEXT, |
126 | $content['archiveUrl'] ?? '', |
127 | $content['isArchived'] ?? false, |
128 | $content['isVisible'] ?? true |
129 | ); |
130 | } |
131 | |
132 | /** |
133 | * @return string |
134 | */ |
135 | public function getArchiveUrl() { |
136 | return $this->archiveUrl; |
137 | } |
138 | |
139 | /** |
140 | * @param string $archiveUrl |
141 | */ |
142 | public function setArchiveUrl( $archiveUrl ) { |
143 | $this->archiveUrl = $archiveUrl; |
144 | } |
145 | |
146 | /** |
147 | * @param string $questionText |
148 | */ |
149 | public function setQuestionText( $questionText ) { |
150 | $this->questionText = $questionText; |
151 | } |
152 | |
153 | /** |
154 | * @return bool |
155 | */ |
156 | public function isVisible() { |
157 | return $this->isVisible; |
158 | } |
159 | |
160 | /** |
161 | * @param bool $isVisible |
162 | */ |
163 | public function setVisible( $isVisible ) { |
164 | $this->isVisible = $isVisible; |
165 | } |
166 | |
167 | /** |
168 | * @param int $timestamp |
169 | */ |
170 | public function setTimestamp( $timestamp ) { |
171 | $this->timestamp = $timestamp; |
172 | } |
173 | |
174 | /** |
175 | * @return string |
176 | */ |
177 | public function getContentModel() { |
178 | return $this->contentModel; |
179 | } |
180 | |
181 | } |