22 lines
474 B
PHP
22 lines
474 B
PHP
<?php
|
|
|
|
namespace Tests\Classes;
|
|
|
|
use Carbon\CarbonPeriodImmutable;
|
|
use Illuminate\Support\Carbon;
|
|
|
|
class CarbonPeriodMapper
|
|
{
|
|
public function cast(mixed $data): CarbonPeriodImmutable
|
|
{
|
|
return new CarbonPeriodImmutable(Carbon::parse($data['start']), Carbon::parse($data['end']));
|
|
}
|
|
|
|
public static function rules(): array
|
|
{
|
|
return [
|
|
'start' => ['required', 'date'],
|
|
'end' => ['required', 'date'],
|
|
];
|
|
}
|
|
}
|