Code Coverage |
||||||||||
Lines |
Functions and Methods |
Classes and Traits |
||||||||
Total | |
82.50% |
33 / 40 |
|
33.33% |
1 / 3 |
CRAP | |
0.00% |
0 / 1 |
ExternalSurvey | |
82.50% |
33 / 40 |
|
33.33% |
1 / 3 |
10.54 | |
0.00% |
0 / 1 |
__construct | |
84.00% |
21 / 25 |
|
0.00% |
0 / 1 |
5.10 | |||
getMessages | |
62.50% |
5 / 8 |
|
0.00% |
0 / 1 |
4.84 | |||
toArray | |
100.00% |
7 / 7 |
|
100.00% |
1 / 1 |
1 |
1 | <?php |
2 | |
3 | namespace QuickSurveys; |
4 | |
5 | class ExternalSurvey extends Survey { |
6 | /** |
7 | * @var bool Whether the survey runs on HTTPS or not. |
8 | */ |
9 | private $isInsecure = null; |
10 | |
11 | /** |
12 | * @var string|null The key of the message containing the URL of the external survey. |
13 | * @deprecated this field has been moved to SurveyQuestion |
14 | */ |
15 | private $link; |
16 | |
17 | /** |
18 | * @var string|null The name of the URL parameter filled with the instance token appended to $link. |
19 | * @deprecated this field has been moved to SurveyQuestion |
20 | */ |
21 | private $instanceTokenParameterName; |
22 | |
23 | /** |
24 | * @var string|null |
25 | * @deprecated this field has been moved to SurveyQuestion |
26 | */ |
27 | private $yesMsg; |
28 | |
29 | /** |
30 | * @var string|null |
31 | * @deprecated this field has been moved to SurveyQuestion |
32 | */ |
33 | private $noMsg; |
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 $link |
48 | * @param string|null $instanceTokenParameterName |
49 | * @param string|null $yesMsg |
50 | * @param string|null $noMsg |
51 | */ |
52 | public function __construct( |
53 | $name, |
54 | $coverage, |
55 | array $platforms, |
56 | $privacyPolicy, |
57 | $additionalInfo, |
58 | $confirmMsg, |
59 | SurveyAudience $audience, |
60 | $questions, |
61 | ?string $question = null, |
62 | ?string $description = null, |
63 | ?string $confirmDescription = null, |
64 | ?string $link = null, |
65 | ?string $instanceTokenParameterName = null, |
66 | ?string $yesMsg = null, |
67 | ?string $noMsg = null |
68 | ) { |
69 | parent::__construct( |
70 | $name, |
71 | $coverage, |
72 | $platforms, |
73 | $privacyPolicy, |
74 | $additionalInfo, |
75 | $confirmMsg, |
76 | $audience, |
77 | $questions, |
78 | $question, |
79 | $description, |
80 | $confirmDescription |
81 | ); |
82 | |
83 | if ( $link ) { |
84 | wfDeprecated( 'QuickSurveys survey with link parameter', '1.43' ); |
85 | } |
86 | if ( $instanceTokenParameterName ) { |
87 | wfDeprecated( 'QuickSurveys survey with instanceTokenParameterName parameter', '1.43' ); |
88 | } |
89 | if ( $yesMsg ) { |
90 | wfDeprecated( 'QuickSurveys survey with yesMsg parameter', '1.43' ); |
91 | } |
92 | if ( $noMsg ) { |
93 | wfDeprecated( 'QuickSurveys survey with noMsg parameter', '1.43' ); |
94 | } |
95 | |
96 | $this->link = $link; |
97 | $this->instanceTokenParameterName = $instanceTokenParameterName; |
98 | $this->yesMsg = $yesMsg; |
99 | $this->noMsg = $noMsg; |
100 | } |
101 | |
102 | /** |
103 | * @return string[] |
104 | */ |
105 | public function getMessages(): array { |
106 | $messages = []; |
107 | |
108 | if ( $this->link !== null ) { |
109 | $messages[] = $this->link; |
110 | } |
111 | |
112 | if ( $this->yesMsg !== null ) { |
113 | $messages[] = $this->yesMsg; |
114 | } |
115 | |
116 | if ( $this->noMsg !== null ) { |
117 | $messages[] = $this->noMsg; |
118 | } |
119 | |
120 | return array_merge( parent::getMessages(), $messages ); |
121 | } |
122 | |
123 | public function toArray(): array { |
124 | return parent::toArray() + [ |
125 | 'type' => 'external', |
126 | 'link' => $this->link, |
127 | 'instanceTokenParameterName' => $this->instanceTokenParameterName, |
128 | 'yesMsg' => $this->yesMsg, |
129 | 'noMsg' => $this->noMsg, |
130 | ]; |
131 | } |
132 | } |