Poll::getPollType()   A
last analyzed

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 1
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 bool
74
     *
75
     * @ORM\Column(name="active", type="boolean")
76
     */
77
    private $active;
78
79
    /**
80
     * @var \AppBundle\Entity\Choice
81
     *
82
     * @ORM\ManyToOne(targetEntity="Choice")
83
     * @ORM\JoinColumn(name="burden_id", referencedColumnName="id")
84
     */
85
    private $burden;
86
87
    // Collection of Users who were eligible to vote
88
    private $eligibleVoters;
89
90
    // Number of winners. Nullable as elections only
91
    private $winners;
92
93
    /**
94
     * Constructor.
95
     */
96
    public function __construct()
97
    {
98
        $this->votes = new ArrayCollection();
99
        $this->choices = new ArrayCollection();
100
        $this->start = new \DateTime();
101
    }
102
103
    /**
104
     * Get id.
105
     *
106
     * @return int
107
     */
108
    public function getId(): int
109
    {
110
        return $this->id;
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 name.
125
     *
126
     * @param string $name
127
     *
128
     * @return Poll
129
     */
130
    public function setName(string $name)
131
    {
132
        $this->name = $name;
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 start.
149
     *
150
     * @param \DateTime $start
151
     *
152
     * @return Poll
153
     */
154
    public function setStart(\DateTime $start)
155
    {
156
        $this->start = $start;
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 description.
173
     *
174
     * @param string $description
175
     *
176
     * @return Poll
177
     */
178
    public function setDescription(string $description)
179
    {
180
        $this->description = $description;
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
     * Set creator.
197
     *
198
     * @param \AppBundle\Entity\User $creator
199
     *
200
     * @return Poll
201
     */
202
    public function setCreator(\AppBundle\Entity\User $creator = null)
203
    {
204
        $this->creator = $creator;
205
206
        return $this;
207
    }
208
209
    /**
210
     * Add vote.
211
     *
212
     * @param \AppBundle\Entity\Vote $vote
213
     *
214
     * @return Poll
215
     */
216
    public function addVote(\AppBundle\Entity\Vote $vote)
217
    {
218
        $this->votes[] = $vote;
219
220
        return $this;
221
    }
222
223
    /**
224
     * Remove vote.
225
     *
226
     * @param \AppBundle\Entity\Vote $vote
227
     */
228
    public function removeVote(\AppBundle\Entity\Vote $vote)
229
    {
230
        $this->votes->removeElement($vote);
231
    }
232
233
    /**
234
     * Get votes.
235
     *
236
     * @return \Doctrine\Common\Collections\Collection
237
     */
238
    public function getVotes()
239
    {
240
        return $this->votes;
241
    }
242
243
    /**
244
     * Add choice.
245
     *
246
     * @param \AppBundle\Entity\Choice $choice
247
     *
248
     * @return Poll
249
     */
250
    public function addChoice(\AppBundle\Entity\Choice $choice)
251
    {
252
        $this->choices[] = $choice;
253
254
        return $this;
255
    }
256
257
    /**
258
     * Remove choice.
259
     *
260
     * @param \AppBundle\Entity\Choice $choice
261
     */
262
    public function removeChoice(\AppBundle\Entity\Choice $choice)
263
    {
264
        $this->choices->removeElement($choice);
265
    }
266
267
    /**
268
     * Get choices.
269
     *
270
     * @return \Doctrine\Common\Collections\Collection
271
     */
272
    public function getChoices()
273
    {
274
        return $this->choices;
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 pollType.
289
     *
290
     * @param \AppBundle\Entity\PollType $pollType
291
     *
292
     * @return Poll
293
     */
294
    public function setPollType(\AppBundle\Entity\PollType $pollType = null)
295
    {
296
        $this->pollType = $pollType;
297
298
        return $this;
299
    }
300
301
    /**
302
     * Get active.
303
     *
304
     * @return bool
305
     */
306
	public function getActive(): bool
307
    {
308
	    return $this->active;
309
    }
310
311
    /**
312
     * Set active.
313
     *
314
     * @param bool $active
315
     *
316
     * @return Poll
317
     */
318
    public function setActive(bool $active)
319
    {
320
        $this->active = $active;
321
322
        return $this;
323
    }
324
}
325