Passed
Push — master ( 727abb...ceefce )
by Yannick
07:55 queued 14s
created

CExerciseCategory::getId()   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
c 0
b 0
f 0
nc 1
nop 0
dl 0
loc 3
rs 10
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 Chamilo\CoreBundle\Entity\AbstractResource;
10
use Chamilo\CoreBundle\Entity\Course;
11
use Chamilo\CoreBundle\Entity\ResourceInterface;
12
use Doctrine\ORM\Mapping as ORM;
13
use Gedmo\Mapping\Annotation as Gedmo;
14
use Gedmo\Sortable\Entity\Repository\SortableRepository;
15
use Gedmo\Timestampable\Traits\TimestampableEntity;
16
use Stringable;
17
use Symfony\Component\Validator\Constraints as Assert;
18
19
#[ORM\Table(name: 'c_exercise_category')]
20
#[ORM\Entity(repositoryClass: SortableRepository::class)]
21
class CExerciseCategory extends AbstractResource implements ResourceInterface, Stringable
22
{
23
    use TimestampableEntity;
24
25
    #[ORM\Column(name: 'id', type: 'integer')]
26
    #[ORM\Id]
27
    #[ORM\GeneratedValue]
28
    protected ?int $id = null;
29
30
    #[Gedmo\SortableGroup]
31
    #[ORM\ManyToOne(targetEntity: Course::class)]
32
    #[ORM\JoinColumn(name: 'c_id', referencedColumnName: 'id', nullable: false, onDelete: 'CASCADE')]
33
    protected Course $course;
34
35
    #[Assert\NotBlank]
36
    #[ORM\Column(name: 'title', type: 'string', length: 255, nullable: false)]
37
    protected string $title;
38
39
    #[ORM\Column(name: 'description', type: 'text', nullable: true)]
40
    protected ?string $description;
41
42
    #[Gedmo\SortablePosition]
43
    #[ORM\Column(name: 'position', type: 'integer')]
44
    protected int $position;
45
46
    public function __construct()
47
    {
48
        $this->position = 0;
49
        $this->description = '';
50
    }
51
52
    public function __toString(): string
53
    {
54
        return $this->getTitle();
55
    }
56
57
    /**
58
     * @return int
59
     */
60
    public function getId()
61
    {
62
        return $this->id;
63
    }
64
65
    public function getTitle(): string
66
    {
67
        return $this->title;
68
    }
69
70
    public function setTitle(string $title): self
71
    {
72
        $this->title = $title;
73
74
        return $this;
75
    }
76
77
    public function getDescription(): string
78
    {
79
        return $this->description;
0 ignored issues
show
Bug Best Practice introduced by
The expression return $this->description could return the type null which is incompatible with the type-hinted return string. Consider adding an additional type-check to rule them out.
Loading history...
80
    }
81
82
    public function setDescription(string $description): self
83
    {
84
        $this->description = $description;
85
86
        return $this;
87
    }
88
89
    public function getCourse(): Course
90
    {
91
        return $this->course;
92
    }
93
94
    public function setCourse(Course $course): self
95
    {
96
        $this->course = $course;
97
98
        return $this;
99
    }
100
101
    public function getPosition(): int
102
    {
103
        return $this->position;
104
    }
105
106
    public function setPosition(int $position): self
107
    {
108
        $this->position = $position;
109
110
        return $this;
111
    }
112
113
    public function getResourceIdentifier(): int
114
    {
115
        return $this->getId();
116
    }
117
118
    public function getResourceName(): string
119
    {
120
        return $this->getTitle();
121
    }
122
123
    public function setResourceName(string $name): self
124
    {
125
        return $this->setTitle($name);
126
    }
127
}
128