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