Completed
Push — master ( 1fc0fb...215969 )
by Felix
25:11
created

Period::days()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 8
Code Lines 4

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 8
rs 9.4285
c 0
b 0
f 0
cc 1
eloc 4
nc 1
nop 1
1
<?php
2
3
namespace SchulzeFelix\SearchConsole;
4
5
use Carbon\Carbon;
6
use SchulzeFelix\SearchConsole\Exceptions\InvalidPeriod;
7
8
class Period
9
{
10
    /** @var Carbon */
11
    public $startDate;
12
13
    /** @var Carbon */
14
    public $endDate;
15
16
    public static function create(Carbon $startDate, Carbon $endDate): Period
17
    {
18
        return new static($startDate, $endDate);
19
    }
20
21
    public function __construct(Carbon $startDate, Carbon $endDate)
22
    {
23
        if ($startDate > $endDate) {
24
            throw InvalidPeriod::startDateCannotBeAfterEndDate($startDate, $endDate);
25
        }
26
27
        $this->startDate = $startDate;
28
29
        $this->endDate = $endDate;
30
    }
31
}
32