Passed
Pull Request — develop (#11)
by
unknown
03:46 queued 56s
created

Settings::withinGroupCreationPeriod()   A

Complexity

Conditions 4
Paths 3

Size

Total Lines 7
Code Lines 3

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 4
eloc 3
nc 3
nop 0
dl 0
loc 7
rs 10
c 0
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
        'groups_creation_start_at',
20
        'groups_creation_end_at',
21
    ];
22
23
    /**
24
     * The attributes that should be mutated to dates.
25
     *
26
     * @var array
27
     */
28
    protected $dates = [
29
        'created_at',
30
        'updated_at',
31
        'exchanges_start_at',
32
        'exchanges_end_at',
33
        'enrollments_start_at',
34
        'enrollments_end_at',
35
        'groups_creation_start_at',
36
        'groups_creation_end_at',
37
    ];
38
39
    /**
40
     * Checks whether today's date is within the shift exchanging period.
41
     *
42
     * @return bool
43
     */
44
    public function withinExchangePeriod(): bool
45
    {
46
        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 exist on App\Judite\Models\Settings. Did you mean changes?
Loading history...
Bug introduced by
The property exchanges_end_at does not exist on App\Judite\Models\Settings. Did you mean changes?
Loading history...
47
            return false;
48
        }
49
50
        return $this->exchanges_start_at->isPast() && ! $this->exchanges_end_at->isPast();
51
    }
52
53
    /**
54
     * Checks whether today's date is within the course enrollment period.
55
     *
56
     * @return bool
57
     */
58
    public function withinEnrollmentPeriod(): bool
59
    {
60
        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...
61
            return false;
62
        }
63
64
        return $this->enrollments_start_at->isPast() && ! $this->enrollments_end_at->isPast();
65
    }
66
67
    /**
68
     * Checks whether today's date is within the group creation period.
69
     *
70
     * @return bool
71
     */
72
    public function withinGroupCreationPeriod(): bool
73
    {
74
        if (is_null($this->groups_creation_start_at) || is_null($this->groups_creation_end_at)) {
0 ignored issues
show
Bug introduced by
The property groups_creation_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 groups_creation_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...
75
            return false;
76
        }
77
78
        return $this->groups_creation_start_at->isPast() && ! $this->groups_creation_end_at->isPast();
79
    }
80
}
81