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

CAttendance::getLogs()   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 Chamilo\CoreBundle\Entity\AbstractResource;
10
use Chamilo\CoreBundle\Entity\ResourceInterface;
11
use Chamilo\CourseBundle\Repository\CAttendanceRepository;
12
use Doctrine\Common\Collections\ArrayCollection;
13
use Doctrine\Common\Collections\Collection;
14
use Doctrine\ORM\Mapping as ORM;
15
use Stringable;
16
use Symfony\Component\Validator\Constraints as Assert;
17
18
#[ORM\Table(name: 'c_attendance')]
19
#[ORM\Index(name: 'active', columns: ['active'])]
20
#[ORM\Entity(repositoryClass: CAttendanceRepository::class)]
21
class CAttendance extends AbstractResource implements ResourceInterface, Stringable
22
{
23
    #[ORM\Column(name: 'iid', type: 'integer')]
24
    #[ORM\Id]
25
    #[ORM\GeneratedValue]
26
    protected ?int $iid = null;
27
28
    #[Assert\NotBlank]
29
    #[ORM\Column(name: 'title', type: 'text', nullable: false)]
30
    protected string $title;
31
32
    #[ORM\Column(name: 'description', type: 'text', nullable: true)]
33
    protected ?string $description;
34
35
    #[Assert\NotBlank]
36
    #[ORM\Column(name: 'active', type: 'integer', nullable: false)]
37
    protected int $active;
38
39
    #[ORM\Column(name: 'attendance_qualify_title', type: 'string', length: 255, nullable: true)]
40
    protected ?string $attendanceQualifyTitle = null;
41
42
    #[Assert\NotNull]
43
    #[ORM\Column(name: 'attendance_qualify_max', type: 'integer', nullable: false)]
44
    protected int $attendanceQualifyMax;
45
46
    #[Assert\NotNull]
47
    #[ORM\Column(name: 'attendance_weight', type: 'float', precision: 6, scale: 2, nullable: false)]
48
    protected float $attendanceWeight;
49
50
    #[Assert\NotNull]
51
    #[ORM\Column(name: 'locked', type: 'integer', nullable: false)]
52
    protected int $locked;
53
54
    /**
55
     * @var Collection|CAttendanceCalendar[]
56
     */
57
    #[ORM\OneToMany(targetEntity: CAttendanceCalendar::class, mappedBy: 'attendance', cascade: ['persist', 'remove'])]
58
    protected Collection $calendars;
59
60
    /**
61
     * @var Collection|CAttendanceResult[]
62
     */
63
    #[ORM\OneToMany(targetEntity: CAttendanceResult::class, mappedBy: 'attendance', cascade: ['persist', 'remove'])]
64
    protected Collection $results;
65
66
    /**
67
     * @var Collection|CAttendanceSheetLog[]
68
     */
69
    #[ORM\OneToMany(targetEntity: CAttendanceSheetLog::class, mappedBy: 'attendance', cascade: ['persist', 'remove'])]
70
    protected Collection $logs;
71
72
    public function __construct()
73
    {
74
        $this->description = '';
75
        $this->active = 1;
76
        $this->attendanceQualifyMax = 0;
77
        $this->locked = 0;
78
        $this->calendars = new ArrayCollection();
79
        $this->results = new ArrayCollection();
80
        $this->logs = new ArrayCollection();
81
    }
82
83
    public function __toString(): string
84
    {
85
        return $this->getTitle();
86
    }
87
88
    public function setTitle(string $title): self
89
    {
90
        $this->title = $title;
91
92
        return $this;
93
    }
94
95
    public function getTitle(): string
96
    {
97
        return $this->title;
98
    }
99
100
    public function setDescription(string $description): self
101
    {
102
        $this->description = $description;
103
104
        return $this;
105
    }
106
107
    public function getDescription(): ?string
108
    {
109
        return $this->description;
110
    }
111
112
    public function setActive(int $active): self
113
    {
114
        $this->active = $active;
115
116
        return $this;
117
    }
118
119
    public function getActive(): int
120
    {
121
        return $this->active;
122
    }
123
124
    public function setAttendanceQualifyTitle(string $attendanceQualifyTitle): self
125
    {
126
        $this->attendanceQualifyTitle = $attendanceQualifyTitle;
127
128
        return $this;
129
    }
130
131
    public function getAttendanceQualifyTitle(): ?string
132
    {
133
        return $this->attendanceQualifyTitle;
134
    }
135
136
    public function setAttendanceQualifyMax(int $attendanceQualifyMax): self
137
    {
138
        $this->attendanceQualifyMax = $attendanceQualifyMax;
139
140
        return $this;
141
    }
142
143
    /**
144
     * Get attendanceQualifyMax.
145
     *
146
     * @return int
147
     */
148
    public function getAttendanceQualifyMax()
149
    {
150
        return $this->attendanceQualifyMax;
151
    }
152
153
    public function setAttendanceWeight(float $attendanceWeight): self
154
    {
155
        $this->attendanceWeight = $attendanceWeight;
156
157
        return $this;
158
    }
159
160
    /**
161
     * Get attendanceWeight.
162
     *
163
     * @return float
164
     */
165
    public function getAttendanceWeight()
166
    {
167
        return $this->attendanceWeight;
168
    }
169
170
    public function setLocked(int $locked): self
171
    {
172
        $this->locked = $locked;
173
174
        return $this;
175
    }
176
177
    /**
178
     * Get locked.
179
     *
180
     * @return int
181
     */
182
    public function getLocked()
183
    {
184
        return $this->locked;
185
    }
186
187
    public function getIid(): ?int
188
    {
189
        return $this->iid;
190
    }
191
192
    public function getCalendars(): Collection
193
    {
194
        return $this->calendars;
195
    }
196
197
    public function setCalendars(Collection $calendars): self
198
    {
199
        $this->calendars = $calendars;
200
201
        return $this;
202
    }
203
204
    /**
205
     * @return CAttendanceSheetLog[]|Collection
206
     */
207
    public function getLogs(): array|Collection
208
    {
209
        return $this->logs;
210
    }
211
212
    /**
213
     * @param CAttendanceSheetLog[]|Collection $logs
214
     */
215
    public function setLogs(array|Collection $logs): self
216
    {
217
        $this->logs = $logs;
218
219
        return $this;
220
    }
221
222
    /**
223
     * @return CAttendanceResult[]|Collection
224
     */
225
    public function getResults(): array|Collection
226
    {
227
        return $this->results;
228
    }
229
230
    public function setResults(Collection $results): self
231
    {
232
        $this->results = $results;
233
234
        return $this;
235
    }
236
237
    public function getResourceIdentifier(): int
238
    {
239
        return $this->getIid();
0 ignored issues
show
Bug Best Practice introduced by
The expression return $this->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...
240
    }
241
242
    public function getResourceName(): string
243
    {
244
        return $this->getTitle();
245
    }
246
247
    public function setResourceName(string $name): self
248
    {
249
        return $this->setTitle($name);
250
    }
251
}
252