Passed
Push — develop ( a18085...de8258 )
by Francisco
14:47
created

EnrollmentPresenter   A

Complexity

Total Complexity 4

Size/Duplication

Total Lines 35
Duplicated Lines 0 %

Importance

Changes 0
Metric Value
wmc 4
c 0
b 0
f 0
dl 0
loc 35
rs 10

3 Methods

Rating   Name   Duplication   Size   Complexity  
A getUpdatedAt() 0 3 1
A inlineToString() 0 6 1
A getShiftTag() 0 3 2
1
<?php
2
3
namespace App\Judite\Presenters;
4
5
use Laracasts\Presenter\Presenter;
6
7
class EnrollmentPresenter extends Presenter
8
{
9
    /**
10
     * Get the shift tag of this enrollment.
11
     *
12
     * @param string $placeholder
13
     *
14
     * @return string
15
     */
16
    public function getShiftTag($placeholder = '---')
17
    {
18
        return $this->entity->shift_id ? $this->entity->shift->tag : $placeholder;
19
    }
20
21
    /**
22
     * Get the formatted date of the last update of this enrollment.
23
     *
24
     * @return string
25
     */
26
    public function getUpdatedAt()
27
    {
28
        return $this->entity->updated_at->toDayDateTimeString();
29
    }
30
31
    /**
32
     * Get the string representation of the enrollment.
33
     *
34
     * @return string
35
     */
36
    public function inlineToString()
37
    {
38
        return $this->entity->student->user->name
39
            .' ('.$this->entity->student->student_number.')'
40
            .' - '.$this->getShiftTag()
41
            .' on '.$this->entity->course->name;
42
    }
43
}
44