<?php

namespace App\Services\Alerts;

use Carbon\CarbonImmutable;

class AlertDateRangeResolver
{
    /**
     * @return array{0: CarbonImmutable, 1: CarbonImmutable}
     */
    public function resolve(string $period): array
    {
        $today = CarbonImmutable::today();

        return match ($period) {
            'weekly' => [$today->subDays(7), $today->subDay()],
            'monthly' => [$today->subMonthNoOverflow()->startOfDay(), $today->subDay()],
            default => [$today->subDay(), $today->subDay()],
        };
    }
}
