Simple problems require simple solutions
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 

33 lines
709 B

<?php
namespace App\DTO;
use Spatie\LaravelData\Data;
class DurationResult extends Data
{
/**
* @param int $days
* @param int $weekDays
* @param int $weeks
* @return void
*/
public function __construct(
public int|float $days,
public int|float $weekDays,
public int|float $weeks,
) {
$this->days = $this->formatFloat($days);
$this->weekDays = $this->formatFloat($weekDays);
$this->weeks = $this->formatFloat($weeks);
}
private function formatFloat(int|float $val): int|float
{
if (!is_float($val)) {
return $val;
}
return (float) number_format($val, 5, '.', '');
}
}