Code Coverage
 
Lines
Functions and Methods
Classes and Traits
Total
100.00% covered (success)
100.00%
27 / 27
100.00% covered (success)
100.00%
3 / 3
CRAP
100.00% covered (success)
100.00%
1 / 1
ExternalSurvey
100.00% covered (success)
100.00%
27 / 27
100.00% covered (success)
100.00%
3 / 3
3
100.00% covered (success)
100.00%
1 / 1
 __construct
100.00% covered (success)
100.00%
15 / 15
100.00% covered (success)
100.00%
1 / 1
1
 getMessages
100.00% covered (success)
100.00%
5 / 5
100.00% covered (success)
100.00%
1 / 1
1
 toArray
100.00% covered (success)
100.00%
7 / 7
100.00% covered (success)
100.00%
1 / 1
1
1<?php
2
3namespace QuickSurveys;
4
5class 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     * @var string
23     */
24    private $yesMsg;
25
26    /**
27     * @var string
28     */
29    private $noMsg;
30
31    /**
32     * @param string $name
33     * @param string $question
34     * @param string $description
35     * @param float $coverage
36     * @param array[] $platforms
37     * @param string $privacyPolicy
38     * @param string $additionalInfo
39     * @param string $confirmMsg
40     * @param SurveyAudience $audience
41     * @param string $link
42     * @param string $instanceTokenParameterName
43     * @param ?string $yesMsg
44     * @param ?string $noMsg
45     */
46    public function __construct(
47        $name,
48        $question,
49        $description,
50        $coverage,
51        array $platforms,
52        $privacyPolicy,
53        $additionalInfo,
54        $confirmMsg,
55        SurveyAudience $audience,
56        $link,
57        $instanceTokenParameterName,
58        ?string $yesMsg = null,
59        ?string $noMsg = null
60    ) {
61        parent::__construct(
62            $name,
63            $question,
64            $description,
65            $coverage,
66            $platforms,
67            $privacyPolicy,
68            $additionalInfo,
69            $confirmMsg,
70            $audience
71        );
72
73        $this->link = $link;
74        $this->instanceTokenParameterName = $instanceTokenParameterName;
75        $this->yesMsg = $yesMsg ?? 'ext-quicksurveys-external-survey-yes-button';
76        $this->noMsg = $noMsg ?? 'ext-quicksurveys-external-survey-no-button';
77    }
78
79    /**
80     * @return string[]
81     */
82    public function getMessages(): array {
83        return array_merge( parent::getMessages(), [
84            $this->link,
85            $this->yesMsg,
86            $this->noMsg,
87        ] );
88    }
89
90    public function toArray(): array {
91        return parent::toArray() + [
92            'type' => 'external',
93            'link' => $this->link,
94            'instanceTokenParameterName' => $this->instanceTokenParameterName,
95            'yesMsg' => $this->yesMsg,
96            'noMsg' => $this->noMsg,
97        ];
98    }
99}