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

Period   A

Complexity

Total Complexity 3

Size/Duplication

Total Lines 29
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 1

Importance

Changes 1
Bugs 0 Features 0
Metric Value
wmc 3
c 1
b 0
f 0
lcom 0
cbo 1
dl 0
loc 29
rs 10

3 Methods

Rating   Name   Duplication   Size   Complexity  
A create() 0 4 1
A days() 0 8 1
A __construct() 0 6 1
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