<?php

namespace App\Console\Commands;

use App\Services\TwoFactorAuthService;
use Illuminate\Console\Command;

class CleanupExpiredTwoFactorCodes extends Command
{
    /**
     * The name and signature of the console command.
     *
     * @var string
     */
    protected $signature = 'two-factor:cleanup';

    /**
     * The console command description.
     *
     * @var string
     */
    protected $description = 'Clean up expired two-factor authentication codes and sessions';

    /**
     * Execute the console command.
     */
    public function handle(TwoFactorAuthService $twoFactorService): int
    {
        $this->info('Cleaning up expired two-factor codes and sessions...');

        $twoFactorService->cleanupExpired();

        $this->info('Cleanup completed successfully.');

        return Command::SUCCESS;
    }
}
