Passed
Push — master ( ffbf3a...2a8bd7 )
by Julito
13:18 queued 12s
created

SessionRelCourseRelUser::setVisibility()   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
3
declare(strict_types=1);
4
5
/* For licensing terms, see /license.txt */
6
7
namespace Chamilo\CoreBundle\Entity;
8
9
use ApiPlatform\Core\Annotation\ApiResource;
10
use Chamilo\CoreBundle\Traits\UserTrait;
11
use Doctrine\ORM\Mapping as ORM;
12
use Symfony\Component\Serializer\Annotation\Groups;
13
use Symfony\Component\Validator\Constraints as Assert;
14
15
/**
16
 * Class SessionRelCourseRelUser.
17
 *
18
 * @ApiResource(
19
 *     shortName="SessionCourseSubscription",
20
 *     normalizationContext={"groups"={"session_rel_course_rel_user:read", "user:read"}}
21
 * )
22
 * @ORM\Table(
23
 *     name="session_rel_course_rel_user",
24
 *     indexes={
25
 *         @ORM\Index(name="idx_session_rel_course_rel_user_id_user", columns={"user_id"}),
26
 *         @ORM\Index(name="idx_session_rel_course_rel_user_course_id", columns={"c_id"})
27
 *     }
28
 * )
29
 * @ORM\Entity
30
 */
31
class SessionRelCourseRelUser
32
{
33
    use UserTrait;
34
35
    public const STATUS_STUDENT = 0;
36
    public const STATUS_COURSE_COACH = 2;
37
    /**
38
     * @var string[]
39
     */
40
    public array $statusList = [
41
        0 => 'student',
42
        2 => 'course_coach',
43
    ];
44
45
    /**
46
     * @ORM\Column(name="id", type="integer")
47
     * @ORM\Id
48
     * @ORM\GeneratedValue
49
     */
50
    protected int $id;
51
52
    /**
53
     * @ORM\ManyToOne(targetEntity="Chamilo\CoreBundle\Entity\User", inversedBy="sessionCourseSubscriptions", cascade={"persist"})
54
     * @ORM\JoinColumn(name="user_id", referencedColumnName="id", nullable=false)
55
     */
56
    protected User $user;
57
58
    /**
59
     * @Groups({"session_rel_course_rel_user:read"})
60
     * @ORM\ManyToOne(targetEntity="Session", inversedBy="userCourseSubscriptions", cascade={"persist"})
61
     * @ORM\JoinColumn(name="session_id", referencedColumnName="id", nullable=false)
62
     */
63
    protected Session $session;
64
65
    /**
66
     * @Groups({"session_rel_course_rel_user:read", "session_rel_user:read"})
67
     * @ORM\ManyToOne(targetEntity="Chamilo\CoreBundle\Entity\Course", inversedBy="sessionUserSubscriptions", cascade={"persist"})
68
     * @ORM\JoinColumn(name="c_id", referencedColumnName="id", nullable=false, onDelete="CASCADE")
69
     */
70
    protected Course $course;
71
72
    /**
73
     * @ORM\Column(name="visibility", type="integer")
74
     */
75
    protected int $visibility;
76
77
    /**
78
     * @ORM\Column(name="status", type="integer")
79
     */
80
    protected int $status;
81
82
    /**
83
     * @ORM\Column(name="legal_agreement", type="integer", nullable=false, unique=false)
84
     */
85
    protected int $legalAgreement;
86
87
    /**
88
     * @Assert\Range(
89
     *      min = 0,
90
     *      max = 100,
91
     *      notInRangeMessage = "Progress from {{ min }} to {{ max }} only",
92
     * )
93
     *
94
     * @ORM\Column(name="progress", type="integer")
95
     */
96
    protected int $progress;
97
98
    public function __construct()
99
    {
100
        $this->progress = 0;
101
        $this->visibility = 1;
102
        $this->legalAgreement = 0;
103
        $this->status = self::STATUS_STUDENT;
104
    }
105
106
    public function getSession(): Session
107
    {
108
        return $this->session;
109
    }
110
111
    public function setSession(Session $session): self
112
    {
113
        $this->session = $session;
114
115
        return $this;
116
    }
117
118
    public function getCourse(): Course
119
    {
120
        return $this->course;
121
    }
122
123
    public function setCourse(Course $course): self
124
    {
125
        $this->course = $course;
126
127
        return $this;
128
    }
129
130
    /**
131
     * Get id.
132
     *
133
     * @return int
134
     */
135
    public function getId()
136
    {
137
        return $this->id;
138
    }
139
140
    public function setVisibility(int $visibility): self
141
    {
142
        $this->visibility = $visibility;
143
144
        return $this;
145
    }
146
147
    public function getVisibility(): int
148
    {
149
        return $this->visibility;
150
    }
151
152
    public function setStatus(int $status): self
153
    {
154
        $this->status = $status;
155
156
        return $this;
157
    }
158
159
    public function getStatus(): int
160
    {
161
        return $this->status;
162
    }
163
164
    public function setLegalAgreement(int $legalAgreement): self
165
    {
166
        $this->legalAgreement = $legalAgreement;
167
168
        return $this;
169
    }
170
171
    public function getLegalAgreement(): int
172
    {
173
        return $this->legalAgreement;
174
    }
175
176
    public function getProgress(): int
177
    {
178
        return $this->progress;
179
    }
180
181
    public function setProgress(int $progress): self
182
    {
183
        $this->progress = $progress;
184
185
        return $this;
186
    }
187
}
188