<?php
declare(strict_types=1);

namespace PpPhp\Core\Platform\Console\Commands;

use PpPhp\Core\Platform\Console\AbstractCommand;
use PpPhp\Core\Platform\Event\Scheduler\EventScheduler;

final class SchedulerClearCommand extends AbstractCommand
{
    public function name(): string { return 'scheduler:clear'; }
    public function description(): string { return 'Clear Scheduler events.'; }

    public function handle(array $arguments = []): int
    {
        $scheduler = new EventScheduler();
        $scheduler->dispatchLater('scheduler.clear.sample', 100);
        $scheduler->clear();
        $this->title('PPphp Scheduler Clear');
        $this->line('Pending: ' . $scheduler->statistics()->pending());
        return 0;
    }
}
