Total Complexity | 3 |
Total Lines | 46 |
Duplicated Lines | 0 % |
Changes | 1 | ||
Bugs | 0 | Features | 0 |
1 | <?php |
||
9 | class Period extends SpatiePeriod |
||
10 | { |
||
11 | /** |
||
12 | * @var Carbon |
||
13 | */ |
||
14 | public $startDate; |
||
15 | |||
16 | /** |
||
17 | * @var Carbon |
||
18 | */ |
||
19 | public $endDate; |
||
20 | |||
21 | /** |
||
22 | * PeriodService constructor. |
||
23 | * |
||
24 | * @param Carbon $startDate |
||
25 | * @param Carbon $endDate |
||
26 | * @throws InvalidPeriod |
||
27 | */ |
||
28 | public function __construct(Carbon $startDate, Carbon $endDate) |
||
31 | } |
||
32 | |||
33 | /** |
||
34 | * Retrieve the Period's length in DateInterval. |
||
35 | * |
||
36 | * @return int |
||
37 | */ |
||
38 | public function length(): int |
||
39 | { |
||
40 | return $this->startDate->diff($this->endDate)->days ?? 0; |
||
41 | } |
||
42 | |||
43 | /** |
||
44 | * Offset the Period by its length in days. |
||
45 | * |
||
46 | * @return SpatiePeriod |
||
47 | */ |
||
48 | public function offsetPeriod(): SpatiePeriod |
||
55 | } |
||
56 | } |
||
57 |