Passed
Push — master ( 4d43e7...34bdad )
by Julito
13:39
created

CourseCategory::setDescription()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 5
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 1
eloc 2
nc 1
nop 1
dl 0
loc 5
rs 10
c 0
b 0
f 0
1
<?php
2
/* For licensing terms, see /license.txt */
3
4
namespace Chamilo\CoreBundle\Entity;
5
6
use Doctrine\Common\Collections\ArrayCollection;
7
use Doctrine\ORM\Mapping as ORM;
8
9
/**
10
 * CourseCategory.
11
 *
12
 * @ORM\Table(
13
 *  name="course_category",
14
 *  uniqueConstraints={
15
 *      @ORM\UniqueConstraint(name="code", columns={"code"})
16
 *  },
17
 *  indexes={
18
 *      @ORM\Index(name="parent_id", columns={"parent_id"}),
19
 *      @ORM\Index(name="tree_pos", columns={"tree_pos"})
20
 *  }
21
 * )
22
 * @ORM\Entity(repositoryClass="Chamilo\CoreBundle\Repository\CourseCategoryRepository")
23
 */
24
class CourseCategory
25
{
26
    /**
27
     * @var int
28
     *
29
     * @ORM\Column(name="id", type="integer")
30
     * @ORM\Id
31
     * @ORM\GeneratedValue()
32
     */
33
    protected $id;
34
35
    /**
36
     * @ORM\OneToMany(targetEntity="CourseCategory", mappedBy="parent")
37
     */
38
    protected $children;
39
40
    /**
41
     * @var string
42
     *
43
     * @ORM\Column(name="name", type="text", nullable=false)
44
     */
45
    protected $name;
46
47
    /**
48
     * @var string
49
     *
50
     * @ORM\Column(name="code", type="string", length=40, nullable=false)
51
     */
52
    protected $code;
53
54
    /**
55
     * @ORM\ManyToOne(targetEntity="CourseCategory", inversedBy="children")
56
     * @ORM\JoinColumn(name="parent_id", referencedColumnName="id")
57
     */
58
    protected $parent;
59
60
    /**
61
     * @var int
62
     *
63
     * @ORM\Column(name="tree_pos", type="integer", nullable=true)
64
     */
65
    protected $treePos;
66
67
    /**
68
     * @var int
69
     *
70
     * @ORM\Column(name="children_count", type="smallint", nullable=true)
71
     */
72
    protected $childrenCount;
73
74
    /**
75
     * @var string
76
     *
77
     * @ORM\Column(name="auth_course_child", type="string", length=40, nullable=true)
78
     */
79
    protected $authCourseChild;
80
81
    /**
82
     * @var string
83
     *
84
     * @ORM\Column(name="auth_cat_child", type="string", length=40, nullable=true)
85
     */
86
    protected $authCatChild;
87
88
    /**
89
     * @var string
90
     *
91
     * @ORM\Column(name="image", type="string", length=255, nullable=true)
92
     */
93
    protected $image;
94
95
    /**
96
     * @var string
97
     *
98
     * @ORM\Column(name="description", type="text", nullable=true)
99
     */
100
    protected $description;
101
102
    /**
103
     * Constructor.
104
     */
105
    public function __construct()
106
    {
107
        $this->childrenCount = 0;
108
        $this->children = new ArrayCollection();
109
    }
110
111
    /**
112
     * @return string
113
     */
114
    public function __toString()
115
    {
116
        $name = strip_tags($this->name);
117
118
        return "$name ({$this->code})";
119
    }
120
121
    /**
122
     * Get id.
123
     *
124
     * @return int
125
     */
126
    public function getId()
127
    {
128
        return $this->id;
129
    }
130
131
    /**
132
     * @return CourseCategory
133
     */
134
    public function getParent()
135
    {
136
        return $this->parent;
137
    }
138
139
    /**
140
     * @return ArrayCollection
141
     */
142
    public function getChildren()
143
    {
144
        return $this->children;
145
    }
146
147
    /**
148
     * @param CourseCategory $child
149
     */
150
    public function addChild(CourseCategory $child)
151
    {
152
        $this->children[] = $child;
153
        $child->setParent($this);
154
    }
155
156
    /**
157
     * @param CourseCategory $parent
158
     */
159
    public function setParent(CourseCategory $parent)
160
    {
161
        $this->parent = $parent;
162
    }
163
164
    /**
165
     * Set name.
166
     *
167
     * @param string $name
168
     *
169
     * @return CourseCategory
170
     */
171
    public function setName($name)
172
    {
173
        $this->name = $name;
174
175
        return $this;
176
    }
177
178
    /**
179
     * Get name.
180
     *
181
     * @return string
182
     */
183
    public function getName()
184
    {
185
        return $this->name;
186
    }
187
188
    /**
189
     * Set code.
190
     *
191
     * @param string $code
192
     *
193
     * @return CourseCategory
194
     */
195
    public function setCode($code)
196
    {
197
        $this->code = $code;
198
199
        return $this;
200
    }
201
202
    /**
203
     * Get code.
204
     *
205
     * @return string
206
     */
207
    public function getCode()
208
    {
209
        return $this->code;
210
    }
211
212
    /**
213
     * Set parentId.
214
     *
215
     * @param string $parentId
216
     *
217
     * @return CourseCategory
218
     */
219
    public function setParentId($parentId)
220
    {
221
        $this->parentId = $parentId;
0 ignored issues
show
Bug Best Practice introduced by
The property parentId does not exist. Although not strictly required by PHP, it is generally a best practice to declare properties explicitly.
Loading history...
222
223
        return $this;
224
    }
225
226
    /**
227
     * Get parentId.
228
     *
229
     * @return string
230
     */
231
    public function getParentId()
232
    {
233
        return $this->parentId;
234
    }
235
236
    /**
237
     * Set treePos.
238
     *
239
     * @param int $treePos
240
     *
241
     * @return CourseCategory
242
     */
243
    public function setTreePos($treePos)
244
    {
245
        $this->treePos = $treePos;
246
247
        return $this;
248
    }
249
250
    /**
251
     * Get treePos.
252
     *
253
     * @return int
254
     */
255
    public function getTreePos()
256
    {
257
        return $this->treePos;
258
    }
259
260
    /**
261
     * Set childrenCount.
262
     *
263
     * @param int $childrenCount
264
     *
265
     * @return CourseCategory
266
     */
267
    public function setChildrenCount($childrenCount)
268
    {
269
        $this->childrenCount = $childrenCount;
270
271
        return $this;
272
    }
273
274
    /**
275
     * Get childrenCount.
276
     *
277
     * @return int
278
     */
279
    public function getChildrenCount()
280
    {
281
        return $this->childrenCount;
282
    }
283
284
    /**
285
     * Set authCourseChild.
286
     *
287
     * @param string $authCourseChild
288
     *
289
     * @return CourseCategory
290
     */
291
    public function setAuthCourseChild($authCourseChild)
292
    {
293
        $this->authCourseChild = $authCourseChild;
294
295
        return $this;
296
    }
297
298
    /**
299
     * Get authCourseChild.
300
     *
301
     * @return string
302
     */
303
    public function getAuthCourseChild()
304
    {
305
        return $this->authCourseChild;
306
    }
307
308
    /**
309
     * Set authCatChild.
310
     *
311
     * @param string $authCatChild
312
     *
313
     * @return CourseCategory
314
     */
315
    public function setAuthCatChild($authCatChild)
316
    {
317
        $this->authCatChild = $authCatChild;
318
319
        return $this;
320
    }
321
322
    /**
323
     * Get authCatChild.
324
     *
325
     * @return string
326
     */
327
    public function getAuthCatChild()
328
    {
329
        return $this->authCatChild;
330
    }
331
332
    /**
333
     * @return string
334
     */
335
    public function getImage(): string
336
    {
337
        return $this->image;
338
    }
339
340
    /**
341
     * @param string $image
342
     *
343
     * @return CourseCategory
344
     */
345
    public function setImage(string $image): CourseCategory
346
    {
347
        $this->image = $image;
348
349
        return $this;
350
    }
351
352
    /**
353
     * @return string
354
     */
355
    public function getDescription(): string
356
    {
357
        return $this->description;
358
    }
359
360
    /**
361
     * @param string $description
362
     *
363
     * @return CourseCategory
364
     */
365
    public function setDescription(string $description): CourseCategory
366
    {
367
        $this->description = $description;
368
369
        return $this;
370
    }
371
372
}
373