Code Coverage |
||||||||||
Lines |
Functions and Methods |
Classes and Traits |
||||||||
Total | |
0.00% |
0 / 5 |
|
0.00% |
0 / 3 |
CRAP | |
0.00% |
0 / 1 |
EventAggregatedAnswers | |
0.00% |
0 / 5 |
|
0.00% |
0 / 3 |
20 | |
0.00% |
0 / 1 |
addEntry | |
0.00% |
0 / 3 |
|
0.00% |
0 / 1 |
6 | |||
getQuestionData | |
0.00% |
0 / 1 |
|
0.00% |
0 / 1 |
2 | |||
getData | |
0.00% |
0 / 1 |
|
0.00% |
0 / 1 |
2 |
1 | <?php |
2 | |
3 | declare( strict_types=1 ); |
4 | |
5 | namespace MediaWiki\Extension\CampaignEvents\Questions; |
6 | |
7 | /** |
8 | * Value object representing the aggregated data of the event. |
9 | */ |
10 | class EventAggregatedAnswers { |
11 | /** @var array<int,array<int,int>> */ |
12 | private array $data = []; |
13 | |
14 | /** |
15 | * @param int $questionID |
16 | * @param int $optionID |
17 | * @param int $amount |
18 | */ |
19 | public function addEntry( int $questionID, int $optionID, int $amount ) { |
20 | if ( !isset( $this->data[ $questionID ] ) ) { |
21 | $this->data[ $questionID ] = []; |
22 | } |
23 | |
24 | $this->data[ $questionID ][ $optionID ] = $amount; |
25 | } |
26 | |
27 | /** |
28 | * Returns the raw data for a given question. |
29 | * |
30 | * @param int $questionID |
31 | * @return array<int,int> Map of [ answer ID => number of answers ] |
32 | */ |
33 | public function getQuestionData( int $questionID ): array { |
34 | return $this->data[$questionID] ?? []; |
35 | } |
36 | |
37 | /** |
38 | * @return array |
39 | */ |
40 | public function getData() { |
41 | return $this->data; |
42 | } |
43 | } |