Completed
Pull Request — dev (#24)
by
unknown
04:06
created

SurveyQuestion::setSurveys()   A

Complexity

Conditions 2
Paths 2

Size

Total Lines 9
Code Lines 5

Duplication

Lines 9
Ratio 100 %

Code Coverage

Tests 0
CRAP Score 6

Importance

Changes 0
Metric Value
dl 9
loc 9
rs 9.6666
c 0
b 0
f 0
ccs 0
cts 5
cp 0
cc 2
eloc 5
nc 2
nop 1
crap 6

1 Method

Rating   Name   Duplication   Size   Complexity  
A SurveyQuestion::getSurveyTypeSection() 0 4 1
1
<?php
2
3
namespace AppBundle\Entity;
4
5
use Doctrine\ORM\Mapping as ORM;
6
use Symfony\Component\Validator\Constraints as Assert;
7
use Symfony\Component\Serializer\Annotation\Groups;
8
use Doctrine\Common\Collections\ArrayCollection;
9
10
/**
11
 * SurveyQuestion.
12
 *
13
 * @ORM\Entity(repositoryClass="AppBundle\Repository\SurveyQuestionRepository")
14
 */
15
class SurveyQuestion
16
{
17
    /**
18
     * @var int
19
     *
20
     * @ORM\Column(type="integer")
21
     * @ORM\Id
22
     * @ORM\GeneratedValue(strategy="AUTO")
23
     * @Groups({"group2", "group3"})
24
     */
25
    private $id;
26
27
    /**
28
     * @var string
29
     * @Assert\NotBlank()
30
     * @Assert\Type("string")
31
     * @Assert\Length(
32
     *      max = 500
33
     * )
34
     * @ORM\Column(type="string")
35
     * @Groups({"group2"})
36
     */
37
    private $title;
38
39
    /**
40
     * @var SurveyTypeSection
41
     * @Assert\Type("object")
42
     * @Assert\Valid
43
     * @ORM\ManyToOne(targetEntity="SurveyTypeSection", inversedBy="questions")
44
     */
45
    private $surveyTypeSection;
46
47
    /**
48
     * @var int
49
     * @Assert\NotBlank()
50
     * @Assert\Type("integer")
51
     * @ORM\Column(type="integer")
52
     * @Groups({"group2"})
53
     */
54
    private $orderNumber;
55
56
    /**
57
     * @var array
58
     * @Assert\NotBlank()
59
     * @Assert\Type("array")
60
     * @ORM\Column(type="array")
61
     * @Groups({"group2"})
62
     */
63
    private $variants;
64
65
    /**
66
     * @var ArrayCollection[SurveyAnswer]
67
     * @ORM\OneToMany(targetEntity="SurveyAnswer", mappedBy="question", cascade={"persist", "remove"})
68
     */
69
    private $answers;
70
71
    public function __construct()
72
    {
73
        $this->answers = new ArrayCollection();
74
        $this->variants = array();
75
    }
76
77
    /**
78
     * Get id.
79
     *
80
     * @return int
81
     */
82 3
    public function getId()
83
    {
84 3
        return $this->id;
85
    }
86
87
    /**
88
     * Set title.
89
     *
90
     * @param string $title
91
     *
92
     * @return SurveyQuestion
93
     */
94
    public function setTitle($title)
95
    {
96
        $this->title = $title;
97
98
        return $this;
99
    }
100
101
    /**
102
     * Get title.
103
     *
104
     * @return string
105
     */
106 3
    public function getTitle()
107
    {
108 3
        return $this->title;
109
    }
110
111
    /**
112
     * Set Survey Type Section.
113
     *
114
     * @param SurveyTypeSection $section
115
     *
116
     * @return SurveyQuestion
117
     */
118
    public function setSurveyTypeSection(SurveyTypeSection $section)
119
    {
120
        $this->surveyTypeSection = $section;
121
122
        return $this;
123
    }
124
125
    /**
126
     * Get Survey Type.
127
     *
128
     * @return SurveyTypeSection
129
     */
130
    public function getSurveyTypeSection()
131
    {
132
        return $this->surveyTypeSection;
133
    }
134
135
    /**
136
     * Set order number.
137
     *
138
     * @param int $number
139
     *
140
     * @return SurveyQuestion
141
     */
142
    public function setOrderNumber($number)
143
    {
144
        $this->orderNumber = $number;
145
146
        return $this;
147
    }
148
149
    /**
150
     * Get order number.
151
     *
152
     * @return int
153
     */
154
    public function getOrderNumber()
155
    {
156
        return $this->orderNumber;
157
    }
158
159
    /**
160
     * Set variants.
161
     *
162
     * @param array $variants
163
     *
164
     * @return SurveyQuestion
165
     */
166
    public function setVariants($variants)
167
    {
168
        $this->variants = $variants;
169
170
        return $this;
171
    }
172
173
    /**
174
     * Add variant.
175
     *
176
     * @param string $variant
177
     *
178
     * @return SurveyQuestion
179
     */
180
    public function addVariant($variant)
181
    {
182
        if (!in_array($variant, $this->variants)) {
183
            $this->variants[] = $variant;
184
        }
185
186
        return $this;
187
    }
188
189
    /**
190
     * Get variants.
191
     *
192
     * @return array
193
     */
194 4
    public function getVariants()
195
    {
196 4
        return $this->variants;
197
    }
198
199
    /**
200
     * Get answers.
201
     *
202
     * @return ArrayCollection
203
     */
204
    public function getAnswers()
205
    {
206
        return $this->answers;
207
    }
208
}
209