Completed
Push — master ( 0a2a1f...860620 )
by Freek
02:16
created

Period::create()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
c 0
b 0
f 0
dl 0
loc 4
rs 10
cc 1
eloc 2
nc 1
nop 2
1
<?php
2
3
namespace Spatie\Analytics;
4
5
use Carbon\Carbon;
6
use DateTime;
7
8
class Period
9
{
10
    /** @var \DateTime */
11
    public $startDate;
12
13
    /** @var \DateTime */
14
    public $endDate;
15
16
    public static function create(DateTime $startDate, $endDate): Period
17
    {
18
        return new static($startDate, $endDate);
19
    }
20
21
    public static function days(int $numberOfDays): Period
22
    {
23
        $endDate = Carbon::today();
24
25
        $startDate = Carbon::today()->subDays($numberOfDays)->startOfDay();
26
27
        return new static($startDate, $endDate);
28
    }
29
30
    public function __construct(DateTime $startDate, DateTime $endDate)
31
    {
32
        $this->startDate = $startDate;
33
34
        $this->endDate = $endDate;
35
    }
36
}
37