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

MonthDateRange   A

Complexity

Total Complexity 5

Size/Duplication

Total Lines 35
Duplicated Lines 0 %

Coupling/Cohesion

Components 2
Dependencies 1

Importance

Changes 0
Metric Value
wmc 5
lcom 2
cbo 1
dl 0
loc 35
rs 10
c 0
b 0
f 0

3 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 5 1
A getStartOfRange() 0 6 2
A getEndOfRange() 0 6 2
1
<?php
2
3
use Carbon\Carbon;
4
5
class MonthDateRange
6
{
7
    private $start;
8
    private $end;
9
10
    public function __construct($start, $end)
11
    {
12
        $this->start = new Carbon('first of ' . $start);
13
        $this->end = new Carbon('last of '. $end);
14
    }
15
16
    /**
17
     * @param int|null $year
18
     *
19
     * @return Carbon
20
     */
21
    public function getStartOfRange($year = null)
22
    {
23
        $year = ($year === null) ? Carbon::now()->year : $year;
24
25
        return $this->start->copy()->year($year);
26
    }
27
28
    /**
29
     * @param int|null $year
30
     *
31
     * @return Carbon
32
     */
33
    public function getEndOfRange($year = null)
34
    {
35
        $year = ($year === null) ? Carbon::now()->year : $year;
36
37
        return $this->end->copy()->year($year);
38
    }
39
}
40