Code Coverage
 
Lines
Functions and Methods
Classes and Traits
Total
100.00% covered (success)
100.00%
6 / 6
100.00% covered (success)
100.00%
2 / 2
CRAP
100.00% covered (success)
100.00%
1 / 1
CarbonDay
100.00% covered (success)
100.00%
6 / 6
100.00% covered (success)
100.00%
2 / 2
2
100.00% covered (success)
100.00%
1 / 1
 __construct
100.00% covered (success)
100.00%
3 / 3
100.00% covered (success)
100.00%
1 / 1
1
 createFromDay
100.00% covered (success)
100.00%
3 / 3
100.00% covered (success)
100.00%
1 / 1
1
1<?php
2
3declare(strict_types=1);
4
5namespace Engelsystem\Helpers;
6
7use Carbon\Month;
8use Carbon\WeekDay;
9use DateTimeInterface;
10use DateTimeZone;
11
12class 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}