Course::addGroup()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 6

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 6
rs 10
c 0
b 0
f 0
cc 1
nc 1
nop 1
1
<?php
2
3
namespace KI\PublicationBundle\Entity;
4
5
use Doctrine\ORM\Mapping as ORM;
6
use JMS\Serializer\Annotation as JMS;
7
use KI\CoreBundle\Entity\Likeable;
8
use Symfony\Component\Validator\Constraints as Assert;
9
10
/**
11
 * @ORM\Entity
12
 * @JMS\ExclusionPolicy("all")
13
 */
14
class Course extends Likeable
15
{
16
    /**
17
     * Semestre (0: toute l'année, 1: premier, 2: second)
18
     * @ORM\Column(name="semester", type="string", nullable=true)
19
     * @JMS\Expose
20
     * @Assert\Type("string")
21
     */
22
    protected $semester;
23
24
    /**
25
     * Département
26
     * @ORM\Column(name="department", type="string")
27
     * @JMS\Expose
28
     * @Assert\Type("string")
29
     * @Assert\NotBlank()
30
     */
31
    protected $department;
32
33
    /**
34
     * Nombre d'ECTS
35
     * @ORM\Column(name="ects", type="float", nullable=true)
36
     * @JMS\Expose
37
     * @Assert\Type("float")
38
     */
39
    protected $ects;
40
41
    /**
42
     * Permet une sorte de modération
43
     * @ORM\Column(name="active", type="boolean", nullable=true)
44
     * @JMS\Expose
45
     * @Assert\Type("boolean")
46
     */
47
    protected $active;
48
49
    /**
50
     * Groupes de ce cours
51
     * @ORM\Column(name="course_groups", type="array", nullable=true)
52
     * @JMS\Expose
53
     * @Assert\Type("array")
54
     */
55
    protected $groups = [];
56
57
    /**
58
     * Liste des annales de ce cours
59
     * @ORM\OneToMany(targetEntity="KI\PublicationBundle\Entity\Exercice", mappedBy="course", cascade={"persist","remove"})
60
     * @JMS\Expose
61
     * @Assert\Valid()
62
     */
63
    protected $exercices;
64
65
    /**
66
     * Liste des occurrences de ce cours
67
     * @ORM\OneToMany(targetEntity="KI\PublicationBundle\Entity\CourseItem", mappedBy="course", cascade={"persist","remove"})
68
     * @Assert\Valid()
69
     */
70
    protected $courseitems;
71
72
    /**
73
     * Constructor
74
     */
75
    public function __construct()
76
    {
77
        $this->exercices = new \Doctrine\Common\Collections\ArrayCollection();
78
        $this->courseitems = new \Doctrine\Common\Collections\ArrayCollection();
79
    }
80
81
    /**
82
     * Set ects
83
     *
84
     * @param float $ects
85
     * @return Course
86
     */
87
    public function setEcts($ects)
88
    {
89
        $this->ects = $ects;
90
91
        return $this;
92
    }
93
94
    /**
95
     * Get ects
96
     *
97
     * @return float
98
     */
99
    public function getEcts()
100
    {
101
        return $this->ects;
102
    }
103
104
    /**
105
     * Set active
106
     *
107
     * @param boolean $active
108
     * @return Course
109
     */
110
    public function setActive($active)
111
    {
112
        $this->active = $active;
113
114
        return $this;
115
    }
116
117
    /**
118
     * Get active
119
     *
120
     * @return boolean
121
     */
122
    public function getActive()
123
    {
124
        return $this->active;
125
    }
126
127
    /**
128
     * Set semester
129
     *
130
     * @param string $semester
131
     * @return Course
132
     */
133
    public function setSemester($semester)
134
    {
135
        $this->semester = $semester;
136
137
        return $this;
138
    }
139
140
    /**
141
     * Get semester
142
     *
143
     * @return string
144
     */
145
    public function getSemester()
146
    {
147
        return $this->semester;
148
    }
149
150
    /**
151
     * Set department
152
     *
153
     * @param string $department
154
     * @return Course
155
     */
156
    public function setDepartment($department)
157
    {
158
        $this->department = $department;
159
160
        return $this;
161
    }
162
163
    /**
164
     * Get department
165
     *
166
     * @return string
167
     */
168
    public function getDepartment()
169
    {
170
        return $this->department;
171
    }
172
173
    /**
174
     * Add groups
175
     *
176
     * @param string $group
177
     * @return Course
178
     */
179
    public function addGroup($group)
180
    {
181
        $this->groups[] = $group;
182
183
        return $this;
184
    }
185
186
    /**
187
     * Remove groups
188
     *
189
     * @param string $group
190
     */
191
    public function removeGroup($group)
192
    {
193
        if (($key = array_search($group, $this->groups)) !== false) {
194
            unset($this->groups[$key]);
195
        }
196
        $this->groups = array_values($this->groups);
197
    }
198
199
    /**
200
     * Get groups
201
     *
202
     * @return \Doctrine\Common\Collections\Collection
203
     */
204
    public function getGroups()
205
    {
206
        return $this->groups;
207
    }
208
209
    /**
210
     * Add exercices
211
     *
212
     * @param \KI\PublicationBundle\Entity\Exercice $exercices
213
     * @return Course
214
     */
215
    public function addExercice(\KI\PublicationBundle\Entity\Exercice $exercices)
216
    {
217
        $this->exercices[] = $exercices;
218
219
        return $this;
220
    }
221
222
    /**
223
     * Remove exercices
224
     *
225
     * @param \KI\PublicationBundle\Entity\Exercice $exercices
226
     */
227
    public function removeExercice(\KI\PublicationBundle\Entity\Exercice $exercices)
228
    {
229
        $this->exercices->removeElement($exercices);
230
    }
231
232
    /**
233
     * Get exercices
234
     *
235
     * @return \Doctrine\Common\Collections\Collection
236
     */
237
    public function getExercices()
238
    {
239
        return $this->exercices;
240
    }
241
242
    /**
243
     * Set exercices
244
     *
245
     * @return Course
246
     */
247
    public function setExercices($exercices)
248
    {
249
        return $this->exercices = $exercices;
250
    }
251
252
    /**
253
     * Add courseitems
254
     *
255
     * @param \KI\PublicationBundle\Entity\Courseitem $courseitems
256
     * @return Course
257
     */
258
    public function addCourseitem(\KI\PublicationBundle\Entity\Courseitem $courseitems)
259
    {
260
        $this->courseitems[] = $courseitems;
261
262
        return $this;
263
    }
264
265
    /**
266
     * Remove courseitems
267
     *
268
     * @param \KI\PublicationBundle\Entity\Courseitem $courseitems
269
     */
270
    public function removeCourseitem(\KI\PublicationBundle\Entity\Courseitem $courseitems)
271
    {
272
        $this->courseitems->removeElement($courseitems);
273
    }
274
275
    /**
276
     * Get courseitems
277
     *
278
     * @return \Doctrine\Common\Collections\Collection
279
     */
280
    public function getCourseitems()
281
    {
282
        return $this->courseitems;
283
    }
284
285
    /**
286
     * Set courseitems
287
     *
288
     * @return Course
289
     */
290
    public function setCourseitems($courseitems)
291
    {
292
        return $this->courseitems = $courseitems;
293
    }
294
}
295