Completed
Push — master ( 9db26b...a06708 )
by Michael
04:04
created

Poll::getCreator()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 0
CRAP Score 2

Importance

Changes 0
Metric Value
dl 0
loc 4
ccs 0
cts 2
cp 0
rs 10
c 0
b 0
f 0
cc 1
eloc 2
nc 1
nop 0
crap 2
1
<?php
2
3
namespace AppBundle\Entity;
4
5
use Doctrine\Common\Collections\ArrayCollection;
6
use Doctrine\ORM\Mapping as ORM;
7
8
/**
9
 * Poll.
10
 *
11
 * @ORM\Table(name="polls")
12
 * @ORM\Entity(repositoryClass="AppBundle\Repository\PollRepository")
13
 */
14
class Poll
15
{
16
    /**
17
     * @var int
18
     *
19
     * @ORM\Column(name="id", type="integer")
20
     * @ORM\Id
21
     * @ORM\GeneratedValue(strategy="AUTO")
22
     */
23
    private $id;
24
25
    /**
26
     * @var string
27
     *
28
     * @ORM\Column(name="name", type="string", length=255)
29
     */
30
    private $name;
31
32
    /**
33
     * @var \DateTime
34
     *
35
     * @ORM\Column(name="start", type="datetime")
36
     */
37
    private $start;
38
39
    /**
40
     * @var \AppBundle\Entity\User
41
     *
42
     * @ORM\ManyToOne(targetEntity="User", inversedBy="createdPolls")
43
     * @ORM\JoinColumn(name="creator_id", referencedColumnName="id")
44
     */
45
    private $creator;
46
47
    /**
48
     * @var \AppBundle\Entity\PollType
49
     *
50
     * @ORM\ManyToOne(targetEntity="PollType", inversedBy="polls")
51
     * @ORM\JoinColumn(name="poll_type_id", referencedColumnName="id")
52
     */
53
    private $pollType;
54
55
    /**
56
     * @var string
57
     *
58
     * @ORM\Column(name="description", type="text", nullable=true)
59
     */
60
    private $description;
61
62
    /**
63
     * @ORM\OneToMany(targetEntity="Vote", mappedBy="poll")
64
     */
65
    private $votes;
66
67
    /**
68
     * @ORM\ManyToMany(targetEntity="AppBundle\Entity\Choice")
69
     */
70
    private $choices;
71
72
    /**
73
     * @var boolean
74
     *
75
     * @ORM\Column(name="active", type="boolean")
76
     */
77
    private $active;
78
79
    /**
80
     * Constructor.
81
     */
82
    public function __construct()
83
    {
84
        $this->votes = new ArrayCollection();
85
        $this->choices = new ArrayCollection();
86
        $this->start = new \DateTime();
87
    }
88
89
    /**
90
     * Get id.
91
     *
92
     * @return int
93
     */
94
    public function getId(): int
95
    {
96
        return $this->id;
97
    }
98
99
    /**
100
     * Set name.
101
     *
102
     * @param string $name
103
     *
104
     * @return Poll
105
     */
106
    public function setName(string $name)
107
    {
108
        $this->name = $name;
109
110
        return $this;
111
    }
112
113
    /**
114
     * Get name.
115
     *
116
     * @return string
117
     */
118
    public function getName(): string
119
    {
120
        return $this->name;
121
    }
122
123
    /**
124
     * Set start.
125
     *
126
     * @param \DateTime $start
127
     *
128
     * @return Poll
129
     */
130
    public function setStart(\DateTime $start)
131
    {
132
        $this->start = $start;
133
134
        return $this;
135
    }
136
137
    /**
138
     * Get start.
139
     *
140
     * @return \DateTime
141
     */
142
    public function getStart(): DateTime
143
    {
144
        return $this->start;
145
    }
146
147
    /**
148
     * Set description.
149
     *
150
     * @param string $description
151
     *
152
     * @return Poll
153
     */
154
    public function setDescription(string $description)
155
    {
156
        $this->description = $description;
157
158
        return $this;
159
    }
160
161
    /**
162
     * Get description.
163
     *
164
     * @return string
165
     */
166
    public function getDescription(): string
167
    {
168
        return $this->description;
169
    }
170
171
    /**
172
     * Set creator.
173
     *
174
     * @param \AppBundle\Entity\User $creator
175
     *
176
     * @return Poll
177
     */
178
    public function setCreator(\AppBundle\Entity\User $creator = null)
179
    {
180
        $this->creator = $creator;
181
182
        return $this;
183
    }
184
185
    /**
186
     * Get creator.
187
     *
188
     * @return \AppBundle\Entity\User
189
     */
190
    public function getCreator(): AppBundle\Entity\User
191
    {
192
        return $this->creator;
193
    }
194
195
    /**
196
     * Add vote.
197
     *
198
     * @param \AppBundle\Entity\Vote $vote
199
     *
200
     * @return Poll
201
     */
202
    public function addVote(\AppBundle\Entity\Vote $vote)
203
    {
204
        $this->votes[] = $vote;
205
206
        return $this;
207
    }
208
209
    /**
210
     * Remove vote.
211
     *
212
     * @param \AppBundle\Entity\Vote $vote
213
     */
214
    public function removeVote(\AppBundle\Entity\Vote $vote)
215
    {
216
        $this->votes->removeElement($vote);
217
    }
218
219
    /**
220
     * Get votes.
221
     *
222
     * @return \Doctrine\Common\Collections\Collection
223
     */
224
    public function getVotes()
225
    {
226
        return $this->votes;
227
    }
228
229
    /**
230
     * Add choice.
231
     *
232
     * @param \AppBundle\Entity\Choice $choice
233
     *
234
     * @return Poll
235
     */
236
    public function addChoice(\AppBundle\Entity\Choice $choice)
237
    {
238
        $this->choices[] = $choice;
239
240
        return $this;
241
    }
242
243
    /**
244
     * Remove choice.
245
     *
246
     * @param \AppBundle\Entity\Choice $choice
247
     */
248
    public function removeChoice(\AppBundle\Entity\Choice $choice)
249
    {
250
        $this->choices->removeElement($choice);
251
    }
252
253
    /**
254
     * Get choices.
255
     *
256
     * @return \Doctrine\Common\Collections\Collection
257
     */
258
    public function getChoices()
259
    {
260
        return $this->choices;
261
    }
262
263
    /**
264
     * Set pollType
265
     *
266
     * @param \AppBundle\Entity\PollType $pollType
267
     *
268
     * @return Poll
269
     */
270
    public function setPollType(\AppBundle\Entity\PollType $pollType = null)
271
    {
272
        $this->pollType = $pollType;
273
274
        return $this;
275
    }
276
277
    /**
278
     * Get pollType
279
     *
280
     * @return \AppBundle\Entity\PollType
281
     */
282
    public function getPollType()
283
    {
284
        return $this->pollType;
285
    }
286
287
    /**
288
     * Set active
289
     *
290
     * @param boolean $active
291
     *
292
     * @return Poll
293
     */
294
    public function setActive(bool $active)
295
    {
296
        $this->active = $active;
297
298
        return $this;
299
    }
300
301
    /**
302
     * Get active
303
     *
304
     * @return boolean
305
     */
306
    public function getActive(): bool
307
    {
308
        return $this->active;
309
    }
310
}
311