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

Settings::withinExchangePeriod()   A

Complexity

Conditions 4
Paths 3

Size

Total Lines 7
Code Lines 3

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
cc 4
eloc 3
nc 3
nop 0
dl 0
loc 7
rs 9.2
c 1
b 0
f 0
1
<?php
2
3
namespace App\Judite\Models;
4
5
use Illuminate\Database\Eloquent\Model;
6
7
class Settings extends Model
8
{
9
    /**
10
     * The attributes that are mass assignable.
11
     *
12
     * @var array
13
     */
14
    protected $fillable = [
15
        'exchanges_start_at',
16
        'exchanges_end_at',
17
        'enrollments_start_at',
18
        'enrollments_end_at',
19
    ];
20
21
    /**
22
     * The attributes that should be mutated to dates.
23
     *
24
     * @var array
25
     */
26
    protected $dates = [
27
        'created_at',
28
        'updated_at',
29
        'exchanges_start_at',
30
        'exchanges_end_at',
31
        'enrollments_start_at',
32
        'enrollments_end_at',
33
    ];
34
35
    /**
36
     * Checks whether today's date is within the shift exchanging period.
37
     *
38
     * @return bool
39
     */
40
    public function withinExchangePeriod(): bool
41
    {
42
        if (is_null($this->exchanges_start_at) || is_null($this->exchanges_end_at)) {
0 ignored issues
show
Bug introduced by
The property exchanges_start_at does not seem to exist on App\Judite\Models\Settings. Are you sure there is no database migration missing?

Checks if undeclared accessed properties appear in database migrations and if the creating migration is correct.

Loading history...
Bug introduced by
The property exchanges_end_at does not seem to exist on App\Judite\Models\Settings. Are you sure there is no database migration missing?

Checks if undeclared accessed properties appear in database migrations and if the creating migration is correct.

Loading history...
43
            return false;
44
        }
45
46
        return $this->exchanges_start_at->isPast() && ! $this->exchanges_end_at->isPast();
47
    }
48
49
    /**
50
     * Checks whether today's date is within the course enrollment period.
51
     *
52
     * @return bool
53
     */
54
    public function withinEnrollmentPeriod(): bool
55
    {
56
        if (is_null($this->enrollments_start_at) || is_null($this->enrollments_end_at)) {
0 ignored issues
show
Bug introduced by
The property enrollments_start_at does not seem to exist on App\Judite\Models\Settings. Are you sure there is no database migration missing?

Checks if undeclared accessed properties appear in database migrations and if the creating migration is correct.

Loading history...
Bug introduced by
The property enrollments_end_at does not seem to exist on App\Judite\Models\Settings. Are you sure there is no database migration missing?

Checks if undeclared accessed properties appear in database migrations and if the creating migration is correct.

Loading history...
57
            return false;
58
        }
59
60
        return $this->enrollments_start_at->isPast() && ! $this->enrollments_end_at->isPast();
61
    }
62
}
63