Completed
Push — feature/player-elo-v3 ( e6aec1 )
by Vladimir
02:55
created

Season::getCurrentSeason()   B

Complexity

Conditions 7
Paths 4

Size

Total Lines 14
Code Lines 9

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 14
rs 8.2222
c 0
b 0
f 0
cc 7
eloc 9
nc 4
nop 0
1
<?php
2
3
use Carbon\Carbon;
4
5
class Season
6
{
7
    const WINTER = 'winter';
8
    const SPRING = 'spring';
9
    const SUMMER = 'summer';
10
    const FALL = 'fall';
11
12
    public static function getCurrentSeason()
13
    {
14
        $now = Carbon::now()->month;
15
16
        if (1 <= $now && $now <= 3) {
17
            return self::WINTER;
18
        } elseif (4 <= $now && $now <= 6) {
19
            return self::SPRING;
20
        } elseif (7 <= $now && $now <= 9) {
21
            return self::SUMMER;
22
        }
23
24
        return self::FALL;
25
    }
26
27
    public static function getCurrentSeasonRange()
28
    {
29
        $season = self::getCurrentSeason();
30
31
        switch ($season) {
32
            case self::WINTER:
33
                return self::getWinterSeason();
34
35
            case self::SPRING:
36
                return self::getSpringSeason();
37
38
            case self::SUMMER:
39
                return self::getSummerSeason();
40
41
            default:
42
                return self::getFallSeason();
43
        }
44
    }
45
46
    public static function getWinterSeason()
47
    {
48
        return (new MonthDateRange('January', 'March'));
49
    }
50
51
    public static function getSpringSeason()
52
    {
53
        return (new MonthDateRange('April', 'June'));
54
    }
55
56
    public static function getSummerSeason()
57
    {
58
        return (new MonthDateRange('July', 'September'));
59
    }
60
61
    public static function getFallSeason()
62
    {
63
        return (new MonthDateRange('October', 'December'));
64
    }
65
}
66