Completed
Push — develop ( ccfa35...b4d2ce )
by Francisco
03:19
created

ExchangeRegistryEntry::toStudent()   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
namespace App\Judite\Models;
4
5
use Illuminate\Database\Eloquent\Model;
6
use App\Judite\Contracts\Registry\ExchangeRegistryEntry as ExchangeRegistryEntryContract;
7
8
class ExchangeRegistryEntry extends Model implements ExchangeRegistryEntryContract
9
{
10
    /**
11
     * The table associated with the model.
12
     *
13
     * @var string
14
     */
15
    protected $table = 'log_exchanges';
16
17
    /**
18
     * {@inheritdoc}
19
     */
20
    public function fromShift()
21
    {
22
        return $this->fromShiftRelation;
23
    }
24
25
    /**
26
     * {@inheritdoc}
27
     */
28
    public function toShift()
29
    {
30
        return $this->toShiftRelation;
31
    }
32
33
    /**
34
     * {@inheritdoc}
35
     */
36
    public function fromStudent()
37
    {
38
        return $this->fromStudentRelation;
39
    }
40
41
    /**
42
     * {@inheritdoc}
43
     */
44
    public function toStudent()
45
    {
46
        return $this->toStudentRelation;
47
    }
48
49
    /**
50
     * {@inheritdoc}
51
     */
52
    public function course()
53
    {
54
        return $this->fromShiftRelation->course;
55
    }
56
57
    /**
58
     * {@inheritdoc}
59
     */
60
    public function getDate()
61
    {
62
        return $this->created_at;
0 ignored issues
show
Bug Best Practice introduced by
The expression return $this->created_at returns the type string which is incompatible with the return type mandated by App\Judite\Contracts\Reg...egistryEntry::getDate() of Carbon\Carbon.

In the issue above, the returned value is violating the contract defined by the mentioned interface.

Let's take a look at an example:

interface HasName {
    /** @return string */
    public function getName();
}

class Name {
    public $name;
}

class User implements HasName {
    /** @return string|Name */
    public function getName() {
        return new Name('foo'); // This is a violation of the ``HasName`` interface
                                // which only allows a string value to be returned.
    }
}
Loading history...
63
    }
64
65
    /**
66
     * Get source shift of this recorded exchange.
67
     *
68
     * @return \Illuminate\Database\Eloquent\Relations\BelongsTo
69
     */
70
    public function fromShiftRelation()
71
    {
72
        return $this->belongsTo(Shift::class, 'from_shift_id');
73
    }
74
75
    /**
76
     * Get target shift of this recorded exchange.
77
     *
78
     * @return \Illuminate\Database\Eloquent\Relations\BelongsTo
79
     */
80
    public function toShiftRelation()
81
    {
82
        return $this->belongsTo(Shift::class, 'to_shift_id');
83
    }
84
85
    /**
86
     * Get source student of this recorded exchange.
87
     *
88
     * @return \Illuminate\Database\Eloquent\Relations\BelongsTo
89
     */
90
    public function fromStudentRelation()
91
    {
92
        return $this->belongsTo(Student::class, 'from_student_id');
93
    }
94
95
    /**
96
     * Get target student of this recorded exchange.
97
     *
98
     * @return \Illuminate\Database\Eloquent\Relations\BelongsTo
99
     */
100
    public function toStudentRelation()
101
    {
102
        return $this->belongsTo(Student::class, 'to_student_id');
103
    }
104
}
105