File manager - Edit - /home/linknsbh/cecil-hotel.net/platform/plugins/analytics/src/Period.php
Back
<?php namespace Botble\Analytics; use Botble\Analytics\Exceptions\InvalidPeriod; use Carbon\Carbon; use Carbon\CarbonInterface; class Period { public function __construct(public CarbonInterface $startDate, public CarbonInterface $endDate) { if ($startDate > $endDate) { throw InvalidPeriod::startDateCannotBeAfterEndDate($startDate, $endDate); } } public static function create(CarbonInterface $startDate, CarbonInterface $endDate): self { return new self($startDate, $endDate); } public static function days(int $numberOfDays): self { $endDate = Carbon::today(); $startDate = Carbon::today()->subDays($numberOfDays)->startOfDay(); return new self($startDate, $endDate); } public static function months(int $numberOfMonths): self { $endDate = Carbon::today(); $startDate = Carbon::today()->subMonths($numberOfMonths)->startOfDay(); return new self($startDate, $endDate); } public static function years(int $numberOfYears): self { $endDate = Carbon::today(); $startDate = Carbon::today()->subYears($numberOfYears)->startOfDay(); return new self($startDate, $endDate); } }
| ver. 1.4 |
Github
|
.
| PHP 8.2.31 | Generation time: 0.29 |
proxy
|
phpinfo
|
Settings