Completed
Push — master ( 0b2f36...19d6a1 )
by Freek
08:35
created

Period   A

Complexity

Total Complexity 2

Size/Duplication

Total Lines 24
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 1

Importance

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

2 Methods

Rating   Name   Duplication   Size   Complexity  
A createForNumberOfDays() 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 createForNumberOfDays(int $numberOfDays)
17
    {
18
        $endDate = Carbon::today();
19
20
        $startDate = Carbon::today()->subDays($numberOfDays)->startOfDay();
21
22
        return new static($startDate, $endDate);
23
    }
24
25
    public function __construct(DateTime $startDate, DateTime $endDate)
26
    {
27
        $this->startDate = $startDate;
28
29
        $this->endDate = $endDate;
30
    }
31
}
32