Code Coverage |
||||||||||
Lines |
Functions and Methods |
Classes and Traits |
||||||||
Total | |
86.84% |
33 / 38 |
|
33.33% |
1 / 3 |
CRAP | |
0.00% |
0 / 1 |
InternalSurvey | |
86.84% |
33 / 38 |
|
33.33% |
1 / 3 |
8.15 | |
0.00% |
0 / 1 |
__construct | |
84.62% |
22 / 26 |
|
0.00% |
0 / 1 |
5.09 | |||
getMessages | |
75.00% |
3 / 4 |
|
0.00% |
0 / 1 |
2.06 | |||
toArray | |
100.00% |
8 / 8 |
|
100.00% |
1 / 1 |
1 |
1 | <?php |
2 | |
3 | namespace QuickSurveys; |
4 | |
5 | class InternalSurvey extends Survey { |
6 | /** |
7 | * @var string[]|null The set of i18n message keys of the internal survey answers. |
8 | * @deprecated |
9 | */ |
10 | private $answers; |
11 | |
12 | /** |
13 | * @var bool|null |
14 | * @deprecated |
15 | */ |
16 | private $shuffleAnswersDisplay; |
17 | |
18 | /** |
19 | * @var string|null |
20 | * @deprecated |
21 | */ |
22 | private $freeformTextLabel; |
23 | |
24 | /** |
25 | * @var string|null |
26 | */ |
27 | private $embedElementId; |
28 | |
29 | /** |
30 | * @var string|null |
31 | * @deprecated |
32 | */ |
33 | private $layout; |
34 | |
35 | /** |
36 | * @param string $name |
37 | * @param float $coverage |
38 | * @param array[] $platforms |
39 | * @param string|null $privacyPolicy |
40 | * @param string|null $additionalInfo |
41 | * @param string|null $confirmMsg |
42 | * @param SurveyAudience $audience |
43 | * @param string|SurveyQuestion[] $questions |
44 | * @param string|null $question |
45 | * @param string|null $description |
46 | * @param string|null $confirmDescription |
47 | * @param string[]|null $answers |
48 | * @param bool|null $shuffleAnswersDisplay |
49 | * @param string|null $freeformTextLabel |
50 | * @param string|null $embedElementId |
51 | * @param string|null $layout |
52 | */ |
53 | public function __construct( |
54 | $name, |
55 | $coverage, |
56 | array $platforms, |
57 | $privacyPolicy, |
58 | $additionalInfo, |
59 | $confirmMsg, |
60 | SurveyAudience $audience, |
61 | $questions, |
62 | ?string $question = null, |
63 | ?string $description = null, |
64 | ?string $confirmDescription = null, |
65 | ?array $answers = null, |
66 | ?bool $shuffleAnswersDisplay = null, |
67 | ?string $freeformTextLabel = null, |
68 | ?string $embedElementId = null, |
69 | ?string $layout = null |
70 | ) { |
71 | parent::__construct( |
72 | $name, |
73 | $coverage, |
74 | $platforms, |
75 | $privacyPolicy, |
76 | $additionalInfo, |
77 | $confirmMsg, |
78 | $audience, |
79 | $questions, |
80 | $question, |
81 | $description, |
82 | $confirmDescription |
83 | ); |
84 | |
85 | if ( $answers ) { |
86 | wfDeprecated( 'QuickSurveys survey with answers parameter', '1.43' ); |
87 | } |
88 | if ( $shuffleAnswersDisplay ) { |
89 | wfDeprecated( 'QuickSurveys survey with shuffleAnswersDisplay parameter', '1.43' ); |
90 | } |
91 | if ( $freeformTextLabel ) { |
92 | wfDeprecated( 'QuickSurveys survey with freeformTextLabel parameter', '1.43' ); |
93 | } |
94 | if ( $layout ) { |
95 | wfDeprecated( 'QuickSurveys survey with layout parameter', '1.43' ); |
96 | } |
97 | |
98 | $this->answers = $answers; |
99 | $this->shuffleAnswersDisplay = $shuffleAnswersDisplay; |
100 | $this->freeformTextLabel = $freeformTextLabel; |
101 | $this->embedElementId = $embedElementId; |
102 | $this->layout = $layout; |
103 | } |
104 | |
105 | /** @inheritDoc */ |
106 | public function getMessages(): array { |
107 | $messages = array_merge( parent::getMessages(), $this->answers ?? [] ); |
108 | |
109 | if ( $this->freeformTextLabel ) { |
110 | $messages[] = $this->freeformTextLabel; |
111 | } |
112 | |
113 | return $messages; |
114 | } |
115 | |
116 | public function toArray(): array { |
117 | return parent::toArray() + [ |
118 | 'type' => 'internal', |
119 | 'answers' => $this->answers, |
120 | 'shuffleAnswersDisplay' => $this->shuffleAnswersDisplay, |
121 | 'freeformTextLabel' => $this->freeformTextLabel, |
122 | 'embedElementId' => $this->embedElementId, |
123 | 'layout' => $this->layout, |
124 | ]; |
125 | } |
126 | } |