Code Coverage |
||||||||||
Lines |
Functions and Methods |
Classes and Traits |
||||||||
Total | |
100.00% |
19 / 19 |
|
100.00% |
3 / 3 |
CRAP | |
100.00% |
1 / 1 |
ExternalSurvey | |
100.00% |
19 / 19 |
|
100.00% |
3 / 3 |
3 | |
100.00% |
1 / 1 |
__construct | |
100.00% |
13 / 13 |
|
100.00% |
1 / 1 |
1 | |||
getMessages | |
100.00% |
1 / 1 |
|
100.00% |
1 / 1 |
1 | |||
toArray | |
100.00% |
5 / 5 |
|
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 The key of the message containing the URL of the external survey. |
13 | */ |
14 | private $link; |
15 | |
16 | /** |
17 | * @var string The name of the URL parameter filled with the instance token appended to $link. |
18 | */ |
19 | private $instanceTokenParameterName; |
20 | |
21 | /** |
22 | * @param string $name |
23 | * @param string $question |
24 | * @param string $description |
25 | * @param float $coverage |
26 | * @param array[] $platforms |
27 | * @param string $privacyPolicy |
28 | * @param string $additionalInfo |
29 | * @param string $confirmMsg |
30 | * @param SurveyAudience $audience |
31 | * @param string $link |
32 | * @param string $instanceTokenParameterName |
33 | */ |
34 | public function __construct( |
35 | $name, |
36 | $question, |
37 | $description, |
38 | $coverage, |
39 | array $platforms, |
40 | $privacyPolicy, |
41 | $additionalInfo, |
42 | $confirmMsg, |
43 | SurveyAudience $audience, |
44 | $link, |
45 | $instanceTokenParameterName |
46 | ) { |
47 | parent::__construct( |
48 | $name, |
49 | $question, |
50 | $description, |
51 | $coverage, |
52 | $platforms, |
53 | $privacyPolicy, |
54 | $additionalInfo, |
55 | $confirmMsg, |
56 | $audience |
57 | ); |
58 | |
59 | $this->link = $link; |
60 | $this->instanceTokenParameterName = $instanceTokenParameterName; |
61 | } |
62 | |
63 | /** |
64 | * @return string[] |
65 | */ |
66 | public function getMessages(): array { |
67 | return array_merge( parent::getMessages(), [ $this->link ] ); |
68 | } |
69 | |
70 | public function toArray(): array { |
71 | return parent::toArray() + [ |
72 | 'type' => 'external', |
73 | 'link' => $this->link, |
74 | 'instanceTokenParameterName' => $this->instanceTokenParameterName, |
75 | ]; |
76 | } |
77 | } |