<?php

declare(strict_types=1);

namespace App\Console\Commands;

use App\Services\Support\SlaService;
use Illuminate\Console\Command;

class CheckSlaBreachCommand extends Command
{
    protected $signature = 'sla:check-breaches';

    protected $description = 'Check all open tickets for SLA breaches and update breach flags';

    public function handle(SlaService $slaService): int
    {
        $breachCount = $slaService->checkBreaches();

        if ($breachCount > 0) {
            $this->warn("Found {$breachCount} SLA breach(es).");
        } else {
            $this->info('No SLA breaches found.');
        }

        return self::SUCCESS;
    }
}
