<?php

namespace App\Commands;

use App\Services\Billing\CreditService;
use CodeIgniter\CLI\BaseCommand;
use CodeIgniter\CLI\CLI;

class CreditExpiryCheck extends BaseCommand
{
    protected $group       = 'Scheduler';
    protected $name        = 'credit:expiry-check';
    protected $description = 'Expires time-limited bonus credits past their expires_at date.';

    public function run(array $params)
    {
        $count = (new CreditService())->runExpiryCheck();
        CLI::write("Expired credits on {$count} transaction(s).", 'yellow');
    }
}
