Code Coverage |
||||||||||
Lines |
Functions and Methods |
Classes and Traits |
||||||||
Total | |
0.00% |
0 / 13 |
|
0.00% |
0 / 5 |
CRAP | |
0.00% |
0 / 1 |
Question | |
0.00% |
0 / 13 |
|
0.00% |
0 / 5 |
56 | |
0.00% |
0 / 1 |
__construct | |
0.00% |
0 / 4 |
|
0.00% |
0 / 1 |
6 | |||
getMessageNames | |
0.00% |
0 / 2 |
|
0.00% |
0 / 1 |
2 | |||
getChildren | |
0.00% |
0 / 1 |
|
0.00% |
0 / 1 |
2 | |||
getOptions | |
0.00% |
0 / 1 |
|
0.00% |
0 / 1 |
2 | |||
getConfXml | |
0.00% |
0 / 5 |
|
0.00% |
0 / 1 |
6 |
1 | <?php |
2 | |
3 | namespace MediaWiki\Extension\SecurePoll\Entities; |
4 | |
5 | use MediaWiki\Extension\SecurePoll\Context; |
6 | |
7 | /** |
8 | * Class representing a question, which the voter will answer. There may be |
9 | * more than one question in an election. |
10 | */ |
11 | class Question extends Entity { |
12 | /** @var Option[] */ |
13 | public $options; |
14 | /** @var int|null */ |
15 | public $electionId; |
16 | |
17 | /** |
18 | * Constructor |
19 | * @param Context $context |
20 | * @param array $info Associative array of entity info |
21 | */ |
22 | public function __construct( $context, $info ) { |
23 | parent::__construct( $context, 'question', $info ); |
24 | $this->options = []; |
25 | foreach ( $info['options'] as $optionInfo ) { |
26 | $this->options[] = new Option( $context, $optionInfo ); |
27 | } |
28 | } |
29 | |
30 | /** |
31 | * Get a list of localisable message names. |
32 | * @return array |
33 | */ |
34 | public function getMessageNames() { |
35 | $ballot = $this->getElection()->getBallot(); |
36 | |
37 | return array_merge( $ballot->getMessageNames( $this ), [ 'text' ] ); |
38 | } |
39 | |
40 | /** |
41 | * Get the child entity objects. |
42 | * @return array |
43 | */ |
44 | public function getChildren() { |
45 | return $this->options; |
46 | } |
47 | |
48 | /** |
49 | * @return array |
50 | */ |
51 | public function getOptions() { |
52 | return $this->options; |
53 | } |
54 | |
55 | /** |
56 | * @param array $params |
57 | * @return string |
58 | */ |
59 | public function getConfXml( $params = [] ) { |
60 | $s = "<question>\n" . $this->getConfXmlEntityStuff( $params ); |
61 | foreach ( $this->getOptions() as $option ) { |
62 | $s .= $option->getConfXml( $params ); |
63 | } |
64 | $s .= "</question>\n"; |
65 | |
66 | return $s; |
67 | } |
68 | } |