GitHub Access Token became invalid

It seems like the GitHub access token used for retrieving details about this repository from GitHub became invalid. This might prevent certain types of inspections from being run (in particular, everything related to pull requests).
Please ask an admin of your repository to re-new the access token on this website.
Completed
Push — user-entity ( 435b1a...e96cee )
by Luis Ramón
02:50
created

Agreement::getTrackedHours()   A

Complexity

Conditions 2
Paths 2

Size

Total Lines 11
Code Lines 5

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
c 1
b 0
f 0
dl 0
loc 11
rs 9.4285
cc 2
eloc 5
nc 2
nop 0
1
<?php
2
/*
3
  ÁTICA - Aplicación web para la gestión documental de centros educativos
4
5
  Copyright (C) 2015-2016: Luis Ramón López López
6
7
  This program is free software: you can redistribute it and/or modify
8
  it under the terms of the GNU Affero General Public License as published by
9
  the Free Software Foundation, either version 3 of the License, or
10
  (at your option) any later version.
11
12
  This program is distributed in the hope that it will be useful,
13
  but WITHOUT ANY WARRANTY; without even the implied warranty of
14
  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
15
  GNU Affero General Public License for more details.
16
17
  You should have received a copy of the GNU Affero General Public License
18
  along with this program.  If not, see [http://www.gnu.org/licenses/].
19
*/
20
21
namespace AppBundle\Entity;
22
23
use Doctrine\Common\Collections\ArrayCollection;
24
use Doctrine\Common\Collections\Collection;
25
use Doctrine\ORM\Mapping as ORM;
26
27
/**
28
 * @ORM\Entity(repositoryClass="AgreementRepository")
29
 */
30
class Agreement
31
{
32
    /**
33
     * @ORM\Id
34
     * @ORM\Column(type="integer")
35
     * @ORM\GeneratedValue
36
     * @var int
37
     */
38
    protected $id;
39
40
    /**
41
     * @ORM\Column(type="date", nullable=true)
42
     * @var \DateTime
43
     */
44
    protected $signDate;
45
46
    /**
47
     * @ORM\Column(type="date")
48
     * @var \DateTime
49
     */
50
    protected $fromDate;
51
52
    /**
53
     * @ORM\Column(type="date")
54
     * @var \DateTime
55
     */
56
    protected $toDate;
57
58
    /**
59
     * @ORM\ManyToOne(targetEntity="User", inversedBy="studentAgreements")
60
     * @ORM\JoinColumn(nullable=false)
61
     * @var User
62
     */
63
    protected $student;
64
65
    /**
66
     * @ORM\ManyToOne(targetEntity="User")
67
     * @ORM\JoinColumn(nullable=false)
68
     * @var User
69
     */
70
    protected $workTutor;
71
72
    /**
73
     * @ORM\ManyToOne(targetEntity="User")
74
     * @ORM\JoinColumn(nullable=false)
75
     * @var User
76
     */
77
    protected $educationalTutor;
78
79
    /**
80
     * @ORM\ManyToOne(targetEntity="Workcenter", inversedBy="agreements")
81
     * @ORM\OrderBy({"name"="ASC"})
82
     * @ORM\JoinColumn(nullable=false)
83
     * @var Workcenter
84
     */
85
    protected $workcenter;
86
87
    /**
88
     * @ORM\ManyToMany(targetEntity="Activity")
89
     * @ORM\OrderBy({"code"="ASC", "name"="ASC"})
90
     * @var Collection
91
     */
92
    protected $activities;
93
94
    /**
95
     * @ORM\OneToMany(targetEntity="Visit", mappedBy="agreement")
96
     * @ORM\OrderBy({"when"="ASC"})
97
     * @var Collection
98
     */
99
    protected $visits;
100
101
    /**
102
     * @ORM\OneToMany(targetEntity="Workday", mappedBy="agreement")
103
     * @ORM\OrderBy({"date"="ASC"})
104
     * @var Collection
105
     */
106
    protected $workdays;
107
108
    /**
109
     * @ORM\OneToOne(targetEntity="Report", mappedBy="agreement")
110
     * @var Report
111
     */
112
    protected $report;
113
114
    /**
115
     * Constructor
116
     */
117
    public function __construct()
118
    {
119
        $this->activities = new ArrayCollection();
120
        $this->visits = new ArrayCollection();
121
        $this->workdays = new ArrayCollection();
122
123
        $this->fromDate = new \DateTime();
124
        $this->toDate = new \DateTime();
125
    }
126
127
    public function __toString()
128
    {
129
        return $this->getStudent() ? $this->getStudent() . ' - ' . $this->getWorkcenter() : '';
130
    }
131
132
    /**
133
     * Get id
134
     *
135
     * @return integer
136
     */
137
    public function getId()
138
    {
139
        return $this->id;
140
    }
141
142
    /**
143
     * Set signDate
144
     *
145
     * @param \DateTime $signDate
146
     *
147
     * @return Agreement
148
     */
149
    public function setSignDate($signDate)
150
    {
151
        $this->signDate = $signDate;
152
153
        return $this;
154
    }
155
156
    /**
157
     * Get signDate
158
     *
159
     * @return \DateTime
160
     */
161
    public function getSignDate()
162
    {
163
        return $this->signDate;
164
    }
165
166
    /**
167
     * Set fromDate
168
     *
169
     * @param \DateTime $fromDate
170
     *
171
     * @return Agreement
172
     */
173
    public function setFromDate($fromDate)
174
    {
175
        $this->fromDate = $fromDate;
176
177
        return $this;
178
    }
179
180
    /**
181
     * Get fromDate
182
     *
183
     * @return \DateTime
184
     */
185
    public function getFromDate()
186
    {
187
        return $this->fromDate;
188
    }
189
190
    /**
191
     * Set toDate
192
     *
193
     * @param \DateTime $toDate
194
     *
195
     * @return Agreement
196
     */
197
    public function setToDate($toDate)
198
    {
199
        $this->toDate = $toDate;
200
201
        return $this;
202
    }
203
204
    /**
205
     * Get toDate
206
     *
207
     * @return \DateTime
208
     */
209
    public function getToDate()
210
    {
211
        return $this->toDate;
212
    }
213
214
    /**
215
     * Set student
216
     *
217
     * @param User $student
218
     *
219
     * @return Agreement
220
     */
221
    public function setStudent(User $student)
222
    {
223
        $this->student = $student;
224
225
        return $this;
226
    }
227
228
    /**
229
     * Get student
230
     *
231
     * @return User
232
     */
233
    public function getStudent()
234
    {
235
        return $this->student;
236
    }
237
238
    /**
239
     * Set workTutor
240
     *
241
     * @param User $workTutor
242
     *
243
     * @return Agreement
244
     */
245
    public function setWorkTutor(User $workTutor = null)
246
    {
247
        $this->workTutor = $workTutor;
248
249
        return $this;
250
    }
251
252
    /**
253
     * Get workTutor
254
     *
255
     * @return User
256
     */
257
    public function getWorkTutor()
258
    {
259
        return $this->workTutor;
260
    }
261
262
    /**
263
     * Set educationalTutor
264
     *
265
     * @param User $educationalTutor
266
     *
267
     * @return Agreement
268
     */
269
    public function setEducationalTutor(User $educationalTutor = null)
270
    {
271
        $this->educationalTutor = $educationalTutor;
272
273
        return $this;
274
    }
275
276
    /**
277
     * Get educationalTutor
278
     *
279
     * @return User
280
     */
281
    public function getEducationalTutor()
282
    {
283
        return $this->educationalTutor;
284
    }
285
286
    /**
287
     * Set workcenter
288
     *
289
     * @param Workcenter $workcenter
290
     *
291
     * @return Agreement
292
     */
293
    public function setWorkcenter(Workcenter $workcenter = null)
294
    {
295
        $this->workcenter = $workcenter;
296
297
        return $this;
298
    }
299
300
    /**
301
     * Get workcenter
302
     *
303
     * @return Workcenter
304
     */
305
    public function getWorkcenter()
306
    {
307
        return $this->workcenter;
308
    }
309
310
    /**
311
     * Add activity
312
     *
313
     * @param Activity $activity
314
     *
315
     * @return Agreement
316
     */
317
    public function addActivity(Activity $activity)
318
    {
319
        $this->activities[] = $activity;
320
321
        return $this;
322
    }
323
324
    /**
325
     * Remove activity
326
     *
327
     * @param Activity $activity
328
     */
329
    public function removeActivity(Activity $activity)
330
    {
331
        $this->activities->removeElement($activity);
332
    }
333
334
    /**
335
     * Get activities
336
     *
337
     * @return Collection
338
     */
339
    public function getActivities()
340
    {
341
        return $this->activities;
342
    }
343
344
    /**
345
     * Add visit
346
     *
347
     * @param Visit $visit
348
     *
349
     * @return Agreement
350
     */
351
    public function addVisit(Visit $visit)
352
    {
353
        $this->visits[] = $visit;
354
355
        return $this;
356
    }
357
358
    /**
359
     * Remove visit
360
     *
361
     * @param Visit $visit
362
     */
363
    public function removeVisit(Visit $visit)
364
    {
365
        $this->visits->removeElement($visit);
366
    }
367
368
    /**
369
     * Get visits
370
     *
371
     * @return Collection
372
     */
373
    public function getVisits()
374
    {
375
        return $this->visits;
376
    }
377
378
    /**
379
     * Add workday
380
     *
381
     * @param Workday $workday
382
     *
383
     * @return Agreement
384
     */
385
    public function addWorkday(Workday $workday)
386
    {
387
        $this->workdays[] = $workday;
388
389
        return $this;
390
    }
391
392
    /**
393
     * Remove workday
394
     *
395
     * @param Workday $workday
396
     */
397
    public function removeWorkday(Workday $workday)
398
    {
399
        $this->workdays->removeElement($workday);
400
    }
401
402
    /**
403
     * Get workdays
404
     *
405
     * @return Collection
406
     */
407
    public function getWorkdays()
408
    {
409
        return $this->workdays;
410
    }
411
412
    /**
413
     * Set report
414
     *
415
     * @param Report $report
416
     *
417
     * @return Agreement
418
     */
419
    public function setReport(Report $report = null)
420
    {
421
        $this->report = $report;
422
423
        return $this;
424
    }
425
426
    /**
427
     * Get report
428
     *
429
     * @return Report
430
     */
431
    public function getReport()
432
    {
433
        return $this->report;
434
    }
435
436
    /**
437
     * Get total hours
438
     *
439
     * @return float
440
     */
441
    public function getTotalHours()
442
    {
443
        $total = 0.0;
444
445
        /** @var Workday $workday */
446
        foreach ($this->getWorkdays() as $workday) {
447
            $total += $workday->getHours();
448
        }
449
450
        return $total;
451
    }
452
453
    /**
454
     * Get tracked hours
455
     *
456
     * @return float
457
     */
458
    public function getTrackedHours()
459
    {
460
        $total = 0.0;
461
462
        /** @var Workday $workday */
463
        foreach ($this->getWorkdays() as $workday) {
464
            $total += $workday->getTrackedHours();
465
        }
466
467
        return $total;
468
    }
469
470
}
471