<?php

namespace App\Commands;

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

class SubscriptionExpiryCheck extends BaseCommand
{
    protected $group       = 'Scheduler';
    protected $name        = 'subscription:expiry-check';
    protected $description = 'Expires lapsed agency subscriptions and demotes them to the Free plan.';

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