Choice::getName()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 4

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 4
rs 10
c 0
b 0
f 0
cc 1
nc 1
nop 0
1
<?php
2
/*
3
 * Copyright 2014-2016 Arnaud Bienvenu
4
 *
5
 * This file is part of Kyela.
6
7
 * Kyela is free software: you can redistribute it and/or modify
8
 * it under the terms of the GNU Affero General Public License as published by
9
 * the Free Software Foundation, either version 3 of the License, or
10
 * (at your option) any later version.
11
12
 * Kyela is distributed in the hope that it will be useful,
13
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
15
 * GNU Affero General Public License for more details.
16
17
 * You should have received a copy of the GNU Affero General Public License
18
 * along with Kyela.  If not, see <http://www.gnu.org/licenses/>.
19
 *
20
 */
21
22
namespace Abienvenu\KyelaBundle\Entity;
23
24
use Doctrine\Common\Collections\ArrayCollection;
25
use Symfony\Component\Validator\Constraints as Assert;
26
use Doctrine\ORM\Mapping as ORM;
27
28
/**
29
 * Choice
30
 *
31
 * @ORM\Table()
32
 * @ORM\Entity(repositoryClass="Abienvenu\KyelaBundle\Entity\ChoiceRepository")
33
 */
34
class Choice extends Entity
35
{
36
    public function __toString()
37
    {
38
        return $this->name;
39
    }
40
41
    /**
42
     * @var integer
43
     *
44
     * @ORM\Column(name="id", type="integer")
45
     * @ORM\Id
46
     * @ORM\GeneratedValue(strategy="AUTO")
47
     */
48
    private $id;
49
50
    /**
51
     * @var string
52
     *
53
     * @ORM\Column(name="name", type="string", length=64)
54
     * @Assert\NotBlank()
55
     */
56
    private $name;
57
58
    /**
59
     * @var integer
60
     *
61
     * @ORM\Column(name="value", type="integer")
62
     */
63
    private $value;
64
65
    /**
66
     * @var string
67
     *
68
     * @ORM\Column(name="color", type="string", length=16)
69
     */
70
    private $color;
71
72
    /**
73
     * @var string
74
     *
75
     * @ORM\Column(name="icon", type="string", length=16, nullable=true)
76
     */
77
    private $icon;
78
79
    /**
80
     * @var integer
81
     *
82
     * @ORM\Column(name="priority", type="integer")
83
     */
84
    private $priority;
85
86
    /**
87
     * @ORM\OneToMany(targetEntity="Participation", mappedBy="choice", cascade={"remove"})
88
     */
89
    private $participations;
90
91
    /**
92
     * @ORM\ManyToOne(targetEntity="Poll", inversedBy="choices")
93
     */
94
    private $poll;
95
96
    /**
97
     * Get id
98
     *
99
     * @return integer
100
     */
101
    public function getId()
102
    {
103
        return $this->id;
104
    }
105
106
    /**
107
     * Set name
108
     *
109
     * @param string $name
110
     * @return Choice
111
     */
112
    public function setName($name)
113
    {
114
        $this->name = $name;
115
116
        return $this;
117
    }
118
119
    /**
120
     * Get name
121
     *
122
     * @return string
123
     */
124
    public function getName()
125
    {
126
        return $this->name;
127
    }
128
129
    /**
130
     * Set value
131
     *
132
     * @param integer $value
133
     * @return Choice
134
     */
135
    public function setValue($value)
136
    {
137
        $this->value = $value;
138
139
        return $this;
140
    }
141
142
    /**
143
     * Get value
144
     *
145
     * @return integer
146
     */
147
    public function getValue()
148
    {
149
        return $this->value;
150
    }
151
152
    /**
153
     * Set color
154
     *
155
     * @param string $color
156
     * @return Choice
157
     */
158
    public function setColor($color)
159
    {
160
        $this->color = $color;
161
162
        return $this;
163
    }
164
165
    /**
166
     * Get color
167
     *
168
     * @return string
169
     */
170
    public function getColor()
171
    {
172
        return $this->color;
173
    }
174
    /**
175
     * Constructor
176
     */
177
    public function __construct()
178
    {
179
        $this->participations = new ArrayCollection();
180
    }
181
182
    /**
183
     * Add participations
184
     *
185
     * @param Participation $participations
186
     * @return Choice
187
     */
188
    public function addParticipation(Participation $participations)
189
    {
190
        $this->participations[] = $participations;
191
192
        return $this;
193
    }
194
195
    /**
196
     * Remove participations
197
     *
198
     * @param Participation $participations
199
     */
200
    public function removeParticipation(Participation $participations)
201
    {
202
        $this->participations->removeElement($participations);
203
    }
204
205
    /**
206
     * Get participations
207
     *
208
     * @return \Doctrine\Common\Collections\Collection
209
     */
210
    public function getParticipations()
211
    {
212
        return $this->participations;
213
    }
214
215
    /**
216
     * Set poll
217
     *
218
     * @param Poll $poll
219
     * @return Choice
220
     */
221
    public function setPoll(Poll $poll = null)
222
    {
223
        $this->poll = $poll;
224
225
        return $this;
226
    }
227
228
    /**
229
     * Get poll
230
     *
231
     * @return Poll
232
     */
233
    public function getPoll()
234
    {
235
        return $this->poll;
236
    }
237
238
    /**
239
     * Set priority
240
     *
241
     * @param integer $priority
242
     * @return Choice
243
     */
244
    public function setPriority($priority)
245
    {
246
        $this->priority = $priority;
247
248
        return $this;
249
    }
250
251
    /**
252
     * Get priority
253
     *
254
     * @return integer
255
     */
256
    public function getPriority()
257
    {
258
        return $this->priority;
259
    }
260
261
    /**
262
     * Set icon
263
     *
264
     * @param string $icon
265
     * @return Choice
266
     */
267
    public function setIcon($icon)
268
    {
269
        $this->icon = $icon;
270
271
        return $this;
272
    }
273
274
    /**
275
     * Get icon
276
     *
277
     * @return string
278
     */
279
    public function getIcon()
280
    {
281
        return $this->icon;
282
    }
283
}
284