Code Coverage |
||||||||||
Lines |
Functions and Methods |
Classes and Traits |
||||||||
| Total | |
100.00% |
6 / 6 |
|
100.00% |
2 / 2 |
CRAP | |
100.00% |
1 / 1 |
| CarbonDay | |
100.00% |
6 / 6 |
|
100.00% |
2 / 2 |
2 | |
100.00% |
1 / 1 |
| __construct | |
100.00% |
3 / 3 |
|
100.00% |
1 / 1 |
1 | |||
| createFromDay | |
100.00% |
3 / 3 |
|
100.00% |
1 / 1 |
1 | |||
| 1 | <?php |
| 2 | |
| 3 | declare(strict_types=1); |
| 4 | |
| 5 | namespace Engelsystem\Helpers; |
| 6 | |
| 7 | use Carbon\Month; |
| 8 | use Carbon\WeekDay; |
| 9 | use DateTimeInterface; |
| 10 | use DateTimeZone; |
| 11 | |
| 12 | class CarbonDay extends Carbon |
| 13 | { |
| 14 | public function __construct( |
| 15 | float | DateTimeInterface | int | string | WeekDay | Month | null $time = null, |
| 16 | int | DateTimeZone | string | null $timezone = null |
| 17 | ) { |
| 18 | parent::__construct($time, $timezone); |
| 19 | $this->settings(['toStringFormat' => 'Y-m-d', 'toJsonFormat' => 'Y-m-d']); |
| 20 | $this->startOfDay(); |
| 21 | } |
| 22 | |
| 23 | public static function createFromDay(string | int $day, DateTimeZone | string | int | null $timezone = null): ?self |
| 24 | { |
| 25 | return static::createFromFormat('Y-m-d', $day, $timezone) |
| 26 | ->settings(['toStringFormat' => 'Y-m-d', 'toJsonFormat' => 'Y-m-d']) |
| 27 | ->startOfDay(); |
| 28 | } |
| 29 | } |