Passed
Push — master ( c76aa7...6c061b )
by Julito
08:15 queued 11s
created

CLpItem::getLvl()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 3
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 1
eloc 1
nc 1
nop 0
dl 0
loc 3
rs 10
c 0
b 0
f 0
1
<?php
2
3
declare(strict_types=1);
4
5
/* For licensing terms, see /license.txt */
6
7
namespace Chamilo\CourseBundle\Entity;
8
9
use Doctrine\Common\Collections\ArrayCollection;
10
use Doctrine\Common\Collections\Collection;
11
use Doctrine\ORM\Mapping as ORM;
12
use Gedmo\Mapping\Annotation as Gedmo;
13
use Symfony\Component\Validator\Constraints as Assert;
14
15
/**
16
 * CLpItem.
17
 *
18
 * @Gedmo\Tree(type="nested")
19
 * @ORM\Table(
20
 *     name="c_lp_item",
21
 *     indexes={
22
 *         @ORM\Index(name="lp_id", columns={"lp_id"}),
23
 *     }
24
 * )
25
 * @ORM\Entity
26
 */
27
class CLpItem
28
{
29
    /**
30
     * @ORM\Column(name="iid", type="integer")
31
     * @ORM\Id
32
     * @ORM\GeneratedValue
33
     */
34
    protected ?int $iid = null;
35
36
    /**
37
     * @Assert\NotBlank()
38
     *
39
     * @ORM\Column(name="title", type="string", length=511, nullable=false)
40
     */
41
    protected string $title;
42
43
    /**
44
     * @Assert\NotBlank()
45
     *
46
     * @ORM\Column(name="item_type", type="string", length=32, nullable=false)
47
     */
48
    protected string $itemType;
49
50
    /**
51
     * @ORM\Column(name="ref", type="text", nullable=false)
52
     */
53
    protected string $ref;
54
55
    /**
56
     * @ORM\Column(name="description", type="string", length=511, nullable=true)
57
     */
58
    protected ?string $description;
59
60
    /**
61
     * @ORM\Column(name="path", type="text", nullable=false)
62
     */
63
    protected string $path;
64
65
    /**
66
     * @ORM\Column(name="min_score", type="float", precision=10, scale=0, nullable=false)
67
     */
68
    protected float $minScore;
69
70
    /**
71
     * @ORM\Column(name="max_score", type="float", precision=10, scale=0, nullable=true, options={"default":"100"})
72
     */
73
    protected ?float $maxScore;
74
75
    /**
76
     * @ORM\Column(name="mastery_score", type="float", precision=10, scale=0, nullable=true)
77
     */
78
    protected ?float $masteryScore = null;
79
80
    /**
81
     * @ORM\Column(name="display_order", type="integer", nullable=false)
82
     */
83
    protected int $displayOrder;
84
85
    /**
86
     * @ORM\Column(name="prerequisite", type="text", nullable=true)
87
     */
88
    protected ?string $prerequisite = null;
89
90
    /**
91
     * @ORM\Column(name="parameters", type="text", nullable=true)
92
     */
93
    protected ?string $parameters = null;
94
95
    /**
96
     * @ORM\Column(name="launch_data", type="text", nullable=false)
97
     */
98
    protected string $launchData;
99
100
    /**
101
     * @ORM\Column(name="max_time_allowed", type="string", length=13, nullable=true)
102
     */
103
    protected ?string $maxTimeAllowed = null;
104
105
    /**
106
     * @ORM\Column(name="terms", type="text", nullable=true)
107
     */
108
    protected ?string $terms = null;
109
110
    /**
111
     * @ORM\Column(name="search_did", type="integer", nullable=true)
112
     */
113
    protected ?int $searchDid = null;
114
115
    /**
116
     * @ORM\Column(name="audio", type="string", length=250, nullable=true)
117
     */
118
    protected ?string $audio = null;
119
120
    /**
121
     * @ORM\Column(name="prerequisite_min_score", type="float", precision=10, scale=0, nullable=true)
122
     */
123
    protected ?float $prerequisiteMinScore = null;
124
125
    /**
126
     * @ORM\Column(name="prerequisite_max_score", type="float", precision=10, scale=0, nullable=true)
127
     */
128
    protected ?float $prerequisiteMaxScore = null;
129
130
    /**
131
     * @Gedmo\TreeRoot
132
     * @ORM\ManyToOne(targetEntity="Chamilo\CourseBundle\Entity\CLp", inversedBy="items", cascade={"persist"})
133
     * @ORM\JoinColumn(name="lp_id", referencedColumnName="iid")
134
     */
135
    protected CLp $lp;
136
137
    /**
138
     * @Gedmo\TreeParent
139
     * @ORM\ManyToOne(targetEntity="CLpItem", inversedBy="children", cascade="persist")
140
     * @ORM\JoinColumn(name="parent_item_id", referencedColumnName="iid", onDelete="SET NULL")
141
     */
142
    protected ?CLpItem $parent = null;
143
144
    /**
145
     * @var Collection|CLpItem[]
146
     * @ORM\OneToMany(targetEntity="CLpItem", mappedBy="parent")
147
     */
148
    protected Collection $children;
149
150
    /**
151
     * @Gedmo\TreeLeft
152
     * @ORM\Column(name="previous_item_id", type="integer", nullable=true)
153
     */
154
    protected ?int $previousItemId = null;
155
156
    /**
157
     * @Gedmo\TreeRight
158
     * @ORM\Column(name="next_item_id", type="integer", nullable=true)
159
     */
160
    protected ?int $nextItemId = null;
161
162
    /**
163
     * @Gedmo\TreeLevel
164
     * @ORM\Column(name="lvl", type="integer")
165
     */
166
    protected ?int $lvl;
167
168
    public function __construct()
169
    {
170
        $this->children = new ArrayCollection();
171
        $this->path = '';
172
        $this->ref = '';
173
        $this->launchData = '';
174
        $this->description = '';
175
        $this->displayOrder = 0;
176
        $this->minScore = 0;
177
        $this->maxScore = 100.0;
178
    }
179
180
    public function __toString(): string
181
    {
182
        return (string) ($this->getIid().' '.$this->getTitle());
183
    }
184
185
    public function getIid(): ?int
186
    {
187
        return $this->iid;
188
    }
189
190
    public function setLp(CLp $lp): self
191
    {
192
        $this->lp = $lp;
193
194
        return $this;
195
    }
196
197
    public function getLp(): CLp
198
    {
199
        return $this->lp;
200
    }
201
202
    public function setItemType(string $itemType): self
203
    {
204
        $this->itemType = $itemType;
205
206
        return $this;
207
    }
208
209
    /**
210
     * Get itemType.
211
     *
212
     * @return string
213
     */
214
    public function getItemType()
215
    {
216
        return $this->itemType;
217
    }
218
219
    public function setRef(string $ref): self
220
    {
221
        $this->ref = $ref;
222
223
        return $this;
224
    }
225
226
    /**
227
     * Get ref.
228
     *
229
     * @return string
230
     */
231
    public function getRef()
232
    {
233
        return $this->ref;
234
    }
235
236
    public function setTitle(string $title): self
237
    {
238
        $this->title = $title;
239
240
        return $this;
241
    }
242
243
    /**
244
     * Get title.
245
     *
246
     * @return string
247
     */
248
    public function getTitle()
249
    {
250
        return $this->title;
251
    }
252
253
    public function setDescription(string $description): self
254
    {
255
        $this->description = $description;
256
257
        return $this;
258
    }
259
260
    /**
261
     * Get description.
262
     *
263
     * @return string
264
     */
265
    public function getDescription()
266
    {
267
        return $this->description;
268
    }
269
270
    public function setPath(string $path): self
271
    {
272
        $this->path = $path;
273
274
        return $this;
275
    }
276
277
    /**
278
     * Get path.
279
     *
280
     * @return string
281
     */
282
    public function getPath()
283
    {
284
        return $this->path;
285
    }
286
287
    public function setMinScore(float $minScore): self
288
    {
289
        $this->minScore = $minScore;
290
291
        return $this;
292
    }
293
294
    /**
295
     * Get minScore.
296
     *
297
     * @return float
298
     */
299
    public function getMinScore()
300
    {
301
        return $this->minScore;
302
    }
303
304
    public function setMaxScore(float $maxScore): self
305
    {
306
        $this->maxScore = $maxScore;
307
308
        return $this;
309
    }
310
311
    /**
312
     * Get maxScore.
313
     *
314
     * @return float
315
     */
316
    public function getMaxScore()
317
    {
318
        return $this->maxScore;
319
    }
320
321
    public function setMasteryScore(float $masteryScore): self
322
    {
323
        $this->masteryScore = $masteryScore;
324
325
        return $this;
326
    }
327
328
    /**
329
     * Get masteryScore.
330
     *
331
     * @return float
332
     */
333
    public function getMasteryScore()
334
    {
335
        return $this->masteryScore;
336
    }
337
338
    public function setPreviousItemId(int $previousItemId): self
339
    {
340
        $this->previousItemId = $previousItemId;
341
342
        return $this;
343
    }
344
345
    /**
346
     * Get previousItemId.
347
     *
348
     * @return int
349
     */
350
    public function getPreviousItemId()
351
    {
352
        return $this->previousItemId;
353
    }
354
355
    public function setNextItemId(int $nextItemId): self
356
    {
357
        $this->nextItemId = $nextItemId;
358
359
        return $this;
360
    }
361
362
    /**
363
     * Get nextItemId.
364
     *
365
     * @return int
366
     */
367
    public function getNextItemId()
368
    {
369
        return $this->nextItemId;
370
    }
371
372
    public function setDisplayOrder(int $displayOrder): self
373
    {
374
        $this->displayOrder = $displayOrder;
375
376
        return $this;
377
    }
378
379
    /**
380
     * Get displayOrder.
381
     *
382
     * @return int
383
     */
384
    public function getDisplayOrder()
385
    {
386
        return $this->displayOrder;
387
    }
388
389
    public function setPrerequisite(string $prerequisite): self
390
    {
391
        $this->prerequisite = $prerequisite;
392
393
        return $this;
394
    }
395
396
    /**
397
     * Get prerequisite.
398
     *
399
     * @return string
400
     */
401
    public function getPrerequisite()
402
    {
403
        return $this->prerequisite;
404
    }
405
406
    public function setParameters(string $parameters): self
407
    {
408
        $this->parameters = $parameters;
409
410
        return $this;
411
    }
412
413
    /**
414
     * Get parameters.
415
     *
416
     * @return string
417
     */
418
    public function getParameters()
419
    {
420
        return $this->parameters;
421
    }
422
423
    public function setLaunchData(string $launchData): self
424
    {
425
        $this->launchData = $launchData;
426
427
        return $this;
428
    }
429
430
    /**
431
     * Get launchData.
432
     *
433
     * @return string
434
     */
435
    public function getLaunchData()
436
    {
437
        return $this->launchData;
438
    }
439
440
    public function setMaxTimeAllowed(string $maxTimeAllowed): self
441
    {
442
        $this->maxTimeAllowed = $maxTimeAllowed;
443
444
        return $this;
445
    }
446
447
    /**
448
     * Get maxTimeAllowed.
449
     *
450
     * @return string
451
     */
452
    public function getMaxTimeAllowed()
453
    {
454
        return $this->maxTimeAllowed;
455
    }
456
457
    public function setTerms(string $terms): self
458
    {
459
        $this->terms = $terms;
460
461
        return $this;
462
    }
463
464
    /**
465
     * Get terms.
466
     *
467
     * @return string
468
     */
469
    public function getTerms()
470
    {
471
        return $this->terms;
472
    }
473
474
    public function setSearchDid(int $searchDid): self
475
    {
476
        $this->searchDid = $searchDid;
477
478
        return $this;
479
    }
480
481
    /**
482
     * Get searchDid.
483
     *
484
     * @return int
485
     */
486
    public function getSearchDid()
487
    {
488
        return $this->searchDid;
489
    }
490
491
    public function setAudio(string $audio): self
492
    {
493
        $this->audio = $audio;
494
495
        return $this;
496
    }
497
498
    /**
499
     * Get audio.
500
     *
501
     * @return string
502
     */
503
    public function getAudio()
504
    {
505
        return $this->audio;
506
    }
507
508
    public function setPrerequisiteMinScore(float $prerequisiteMinScore): self
509
    {
510
        $this->prerequisiteMinScore = $prerequisiteMinScore;
511
512
        return $this;
513
    }
514
515
    /**
516
     * Get prerequisiteMinScore.
517
     *
518
     * @return float
519
     */
520
    public function getPrerequisiteMinScore()
521
    {
522
        return $this->prerequisiteMinScore;
523
    }
524
525
    public function setPrerequisiteMaxScore(float $prerequisiteMaxScore): self
526
    {
527
        $this->prerequisiteMaxScore = $prerequisiteMaxScore;
528
529
        return $this;
530
    }
531
532
    /**
533
     * Get prerequisiteMaxScore.
534
     *
535
     * @return float
536
     */
537
    public function getPrerequisiteMaxScore()
538
    {
539
        return $this->prerequisiteMaxScore;
540
    }
541
542
    public function getParentItemId(): int
543
    {
544
        if (null === $this->parent) {
545
            return 0;
546
        }
547
548
        return $this->getParent()->getIid();
0 ignored issues
show
Bug Best Practice introduced by
The expression return $this->getParent()->getIid() could return the type null which is incompatible with the type-hinted return integer. Consider adding an additional type-check to rule them out.
Loading history...
549
    }
550
551
    public function getParent(): ?self
552
    {
553
        return $this->parent;
554
    }
555
556
    public function setParent(?self $parent): self
557
    {
558
        $this->parent = $parent;
559
560
        return $this;
561
    }
562
563
    /**
564
     * @return CLpItem[]|Collection
565
     */
566
    public function getChildren()
567
    {
568
        return $this->children;
569
    }
570
571
    /**
572
     * @param CLpItem[]|Collection $children
573
     */
574
    public function setChildren(Collection $children): self
575
    {
576
        $this->children = $children;
577
578
        return $this;
579
    }
580
581
    public function getLvl(): ?int
582
    {
583
        return $this->lvl;
584
    }
585
586
    public function setLvl($lvl): self
587
    {
588
        $this->lvl = $lvl;
589
590
        return $this;
591
    }
592
}
593