Code Coverage
 
Lines
Functions and Methods
Classes and Traits
Total
0.00% covered (danger)
0.00%
0 / 13
0.00% covered (danger)
0.00%
0 / 5
CRAP
0.00% covered (danger)
0.00%
0 / 1
Question
0.00% covered (danger)
0.00%
0 / 13
0.00% covered (danger)
0.00%
0 / 5
56
0.00% covered (danger)
0.00%
0 / 1
 __construct
0.00% covered (danger)
0.00%
0 / 4
0.00% covered (danger)
0.00%
0 / 1
6
 getMessageNames
0.00% covered (danger)
0.00%
0 / 2
0.00% covered (danger)
0.00%
0 / 1
2
 getChildren
0.00% covered (danger)
0.00%
0 / 1
0.00% covered (danger)
0.00%
0 / 1
2
 getOptions
0.00% covered (danger)
0.00%
0 / 1
0.00% covered (danger)
0.00%
0 / 1
2
 getConfXml
0.00% covered (danger)
0.00%
0 / 5
0.00% covered (danger)
0.00%
0 / 1
6
1<?php
2
3namespace MediaWiki\Extension\SecurePoll\Entities;
4
5use 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 */
11class 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    public function getOptions() {
49        return $this->options;
50    }
51
52    public function getConfXml( $params = [] ) {
53        $s = "<question>\n" . $this->getConfXmlEntityStuff( $params );
54        foreach ( $this->getOptions() as $option ) {
55            $s .= $option->getConfXml( $params );
56        }
57        $s .= "</question>\n";
58
59        return $s;
60    }
61}