1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
namespace AppBundle\Entity; |
4
|
|
|
|
5
|
|
|
use Doctrine\ORM\Mapping as ORM; |
6
|
|
|
use AppBundle\Entity\User; |
7
|
|
|
use AppBundle\Entity\Vote; |
8
|
|
|
use Doctrine\Common\Collections\ArrayCollection; |
9
|
|
|
|
10
|
|
|
/** |
11
|
|
|
* Poll |
12
|
|
|
* |
13
|
|
|
* @ORM\Table(name="polls") |
14
|
|
|
* @ORM\Entity(repositoryClass="AppBundle\Repository\PollRepository") |
15
|
|
|
*/ |
16
|
|
|
class Poll |
17
|
|
|
{ |
18
|
|
|
/** |
19
|
|
|
* @var int |
20
|
|
|
* |
21
|
|
|
* @ORM\Column(name="id", type="integer") |
22
|
|
|
* @ORM\Id |
23
|
|
|
* @ORM\GeneratedValue(strategy="AUTO") |
24
|
|
|
*/ |
25
|
|
|
private $id; |
26
|
|
|
|
27
|
|
|
/** |
28
|
|
|
* @var string |
29
|
|
|
* |
30
|
|
|
* @ORM\Column(name="name", type="string", length=255) |
31
|
|
|
*/ |
32
|
|
|
private $name; |
33
|
|
|
|
34
|
|
|
/** |
35
|
|
|
* @var \DateTime |
36
|
|
|
* |
37
|
|
|
* @ORM\Column(name="start", type="datetime") |
38
|
|
|
*/ |
39
|
|
|
private $start; |
40
|
|
|
|
41
|
|
|
/** |
42
|
|
|
* @var \User |
43
|
|
|
* |
44
|
|
|
* @ORM\ManyToOne(targetEntity="User", inversedBy="polls") |
45
|
|
|
* @ORM\JoinColumn(name="creator_id", referencedColumnName="id") |
46
|
|
|
*/ |
47
|
|
|
private $creator; |
48
|
|
|
|
49
|
|
|
/** |
50
|
|
|
* @var \PollType |
51
|
|
|
* |
52
|
|
|
* @ORM\ManyToOne(targetEntity="PollType", inversedBy="polls") |
53
|
|
|
* @ORM\JoinColumn(name="poll_type_id", referencedColumnName="id") |
54
|
|
|
*/ |
55
|
|
|
private $pollType; |
56
|
|
|
|
57
|
|
|
/** |
58
|
|
|
* @var string |
59
|
|
|
* |
60
|
|
|
* @ORM\Column(name="description", type="text", nullable=true) |
61
|
|
|
*/ |
62
|
|
|
private $description; |
63
|
|
|
|
64
|
|
|
/** |
65
|
|
|
* @ORM\OneToMany(targetEntity="Vote", mappedBy="poll") |
66
|
|
|
*/ |
67
|
|
|
private $votes; |
68
|
|
|
|
69
|
|
|
/** |
70
|
|
|
* @ORM\ManyToMany(targetEntity="AppBundle\Entity\Choice") |
71
|
|
|
*/ |
72
|
|
|
private $choices; |
73
|
|
|
|
74
|
|
|
/** |
75
|
|
|
* Constructor |
76
|
|
|
*/ |
77
|
|
|
public function __construct() |
78
|
|
|
{ |
79
|
|
|
$this->votes = new ArrayCollection(); |
80
|
|
|
$this->choices = new ArrayCollection(); |
81
|
|
|
} |
82
|
|
|
|
83
|
|
|
/** |
84
|
|
|
* Get id |
85
|
|
|
* |
86
|
|
|
* @return integer |
87
|
|
|
*/ |
88
|
|
|
public function getId(): int |
89
|
|
|
{ |
90
|
|
|
return $this->id; |
91
|
|
|
} |
92
|
|
|
|
93
|
|
|
/** |
94
|
|
|
* Set name |
95
|
|
|
* |
96
|
|
|
* @param string $name |
97
|
|
|
* |
98
|
|
|
* @return Poll |
99
|
|
|
*/ |
100
|
|
|
public function setName(string $name) |
101
|
|
|
{ |
102
|
|
|
$this->name = $name; |
103
|
|
|
|
104
|
|
|
return $this; |
105
|
|
|
} |
106
|
|
|
|
107
|
|
|
/** |
108
|
|
|
* Get name |
109
|
|
|
* |
110
|
|
|
* @return string |
111
|
|
|
*/ |
112
|
|
|
public function getName(): string |
113
|
|
|
{ |
114
|
|
|
return $this->name; |
115
|
|
|
} |
116
|
|
|
|
117
|
|
|
/** |
118
|
|
|
* Set start |
119
|
|
|
* |
120
|
|
|
* @param \DateTime $start |
121
|
|
|
* |
122
|
|
|
* @return Poll |
123
|
|
|
*/ |
124
|
|
|
public function setStart(\DateTimeInterface $start) |
125
|
|
|
{ |
126
|
|
|
$this->start = $start; |
|
|
|
|
127
|
|
|
|
128
|
|
|
return $this; |
129
|
|
|
} |
130
|
|
|
|
131
|
|
|
/** |
132
|
|
|
* Get start |
133
|
|
|
* |
134
|
|
|
* @return \DateTime |
135
|
|
|
*/ |
136
|
|
|
public function getStart(): DateTime |
137
|
|
|
{ |
138
|
|
|
return $this->start; |
139
|
|
|
} |
140
|
|
|
|
141
|
|
|
/** |
142
|
|
|
* Set description |
143
|
|
|
* |
144
|
|
|
* @param string $description |
145
|
|
|
* |
146
|
|
|
* @return Poll |
147
|
|
|
*/ |
148
|
|
|
public function setDescription(string $description) |
149
|
|
|
{ |
150
|
|
|
$this->description = $description; |
151
|
|
|
|
152
|
|
|
return $this; |
153
|
|
|
} |
154
|
|
|
|
155
|
|
|
/** |
156
|
|
|
* Get description |
157
|
|
|
* |
158
|
|
|
* @return string |
159
|
|
|
*/ |
160
|
|
|
public function getDescription(): string |
161
|
|
|
{ |
162
|
|
|
return $this->description; |
163
|
|
|
} |
164
|
|
|
|
165
|
|
|
/** |
166
|
|
|
* Set creator |
167
|
|
|
* |
168
|
|
|
* @param \AppBundle\Entity\User $creator |
169
|
|
|
* |
170
|
|
|
* @return Poll |
171
|
|
|
*/ |
172
|
|
|
public function setCreator(User $creator = null) |
173
|
|
|
{ |
174
|
|
|
$this->creator = $creator; |
|
|
|
|
175
|
|
|
|
176
|
|
|
return $this; |
177
|
|
|
} |
178
|
|
|
|
179
|
|
|
/** |
180
|
|
|
* Get creator |
181
|
|
|
* |
182
|
|
|
* @return \AppBundle\Entity\User |
183
|
|
|
*/ |
184
|
|
|
public function getCreator(): User |
185
|
|
|
{ |
186
|
|
|
return $this->creator; |
187
|
|
|
} |
188
|
|
|
|
189
|
|
|
/** |
190
|
|
|
* Add vote |
191
|
|
|
* |
192
|
|
|
* @param \AppBundle\Entity\Vote $vote |
193
|
|
|
* |
194
|
|
|
* @return Poll |
195
|
|
|
*/ |
196
|
|
|
public function addVote(Vote $vote) |
197
|
|
|
{ |
198
|
|
|
$this->votes[] = $vote; |
199
|
|
|
|
200
|
|
|
return $this; |
201
|
|
|
} |
202
|
|
|
|
203
|
|
|
/** |
204
|
|
|
* Remove vote |
205
|
|
|
* |
206
|
|
|
* @param \AppBundle\Entity\Vote $vote |
207
|
|
|
*/ |
208
|
|
|
public function removeVote(Vote $vote) |
209
|
|
|
{ |
210
|
|
|
$this->votes->removeElement($vote); |
211
|
|
|
} |
212
|
|
|
|
213
|
|
|
/** |
214
|
|
|
* Get votes |
215
|
|
|
* |
216
|
|
|
* @return \Doctrine\Common\Collections\Collection |
217
|
|
|
*/ |
218
|
|
|
public function getVotes() |
219
|
|
|
{ |
220
|
|
|
return $this->votes; |
221
|
|
|
} |
222
|
|
|
|
223
|
|
|
/** |
224
|
|
|
* Add choice |
225
|
|
|
* |
226
|
|
|
* @param \AppBundle\Entity\Choice $choice |
227
|
|
|
* |
228
|
|
|
* @return Poll |
229
|
|
|
*/ |
230
|
|
|
public function addChoice(Choice $choice) |
231
|
|
|
{ |
232
|
|
|
$this->choices[] = $choice; |
233
|
|
|
|
234
|
|
|
return $this; |
235
|
|
|
} |
236
|
|
|
|
237
|
|
|
/** |
238
|
|
|
* Remove choice |
239
|
|
|
* |
240
|
|
|
* @param \AppBundle\Entity\Choice $choice |
241
|
|
|
*/ |
242
|
|
|
public function removeChoice(Choice $choice) |
243
|
|
|
{ |
244
|
|
|
$this->choices->removeElement($choice); |
245
|
|
|
} |
246
|
|
|
|
247
|
|
|
/** |
248
|
|
|
* Get choices |
249
|
|
|
* |
250
|
|
|
* @return \Doctrine\Common\Collections\Collection |
251
|
|
|
*/ |
252
|
|
|
public function getChoices() |
253
|
|
|
{ |
254
|
|
|
return $this->choices; |
255
|
|
|
} |
256
|
|
|
} |
257
|
|
|
|
Our type inference engine has found a suspicous assignment of a value to a property. This check raises an issue when a value that can be of a given class or a super-class is assigned to a property that is type hinted more strictly.
Either this assignment is in error or an instanceof check should be added for that assignment.