|
|
- <?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, '.', '');
- }
- }
|