2025-05-28 09:04:15 +02:00

25 lines
607 B
PHP

<?php
namespace App\Domain\Model\Value;
final readonly class Date
{
public function __construct(
public ?int $month,
public ?int $day,
public int $year,
) {
if ($this->month < 1 || $this->month > 12) {
throw new \InvalidArgumentException('Month must be between 1 and 12');
}
if ($this->day < 1 || $this->day > 31) {
throw new \InvalidArgumentException('Day must be between 1 and 31');
}
}
public function __toString(): string
{
return $this->year . '-' . $this->month . '-' . $this->day;
}
}