Completed
Push — feature/player-elo ( a3fab4...3fea36 )
by Vladimir
05:55 queued 03:34
created

Season::getCurrentSeason()   B

Complexity

Conditions 7
Paths 4

Size

Total Lines 14
Code Lines 9

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 6
CRAP Score 8.8142

Importance

Changes 0
Metric Value
dl 0
loc 14
ccs 6
cts 9
cp 0.6667
rs 8.2222
c 0
b 0
f 0
cc 7
eloc 9
nc 4
nop 0
crap 8.8142
1
<?php
2
3
use Carbon\Carbon;
4
5
abstract class Season
6
{
7
    const WINTER = 'winter';
8
    const SPRING = 'spring';
9
    const SUMMER = 'summer';
10
    const FALL = 'fall';
11
12 5
    public static function getCurrentSeason()
13
    {
14 5
        $now = Carbon::now()->month;
15
16 5
        if (1 <= $now && $now <= 3) {
17
            return self::WINTER;
18 5
        } elseif (4 <= $now && $now <= 6) {
19
            return self::SPRING;
20 5
        } elseif (7 <= $now && $now <= 9) {
21 5
            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