<?php

declare(strict_types=1);

/**
 * bin/send_appointment_reminders.php
 *
 * Run every 5-15 minutes. Closes the loop flagged in
 * docs/PHASE_3_SUMMARY.md's "Phase 4 readiness" section:
 * AppointmentService::sendDueReminders() existed since Phase 3 but had
 * no cron entry calling it yet.
 */

require dirname(__DIR__) . '/vendor/autoload.php';
require dirname(__DIR__) . '/app/Core/Autoloader.php';

use App\Core\Autoloader;
use App\Core\Env;
use App\Services\AppointmentService;

Autoloader::register(dirname(__DIR__));
Env::load(dirname(__DIR__) . '/.env');
require dirname(__DIR__) . '/app/Helpers/functions.php';

$sent = (new AppointmentService())->sendDueReminders((int) ($argv[1] ?? 15));

echo date('Y-m-d H:i:s') . " — sent {$sent} appointment reminder(s)\n";
