<?php

declare(strict_types=1);

namespace App\Scolarite\Application\Query\GetChildrenSchedule;

use DateTimeImmutable;
use InvalidArgumentException;

use function sprintf;

final readonly class GetChildrenScheduleQuery
{
    public function __construct(
        public string $parentId,
        public string $tenantId,
        public string $date,
        public ?string $childId = null,
    ) {
        if (DateTimeImmutable::createFromFormat('Y-m-d', $date) === false) {
            throw new InvalidArgumentException(sprintf('Date invalide : "%s". Format attendu : YYYY-MM-DD.', $date));
        }
    }
}
