<?php
declare(strict_types=1);

namespace PpPhp\Core\Platform\Console\Commands;

use PpPhp\Core\Platform\Console\AbstractCommand;
use PpPhp\Core\Platform\Console\ConsolePath;
use PpPhp\Core\Platform\Event\Dispatcher\Runtime\DispatcherRuntimeManager;

final class DispatcherCommand extends AbstractCommand
{
    public function name(): string { return 'dispatcher'; }
    public function description(): string { return 'PPphp Delayed Dispatcher'; }

    public function handle(array $arguments = []): int
    {
        $this->title('PPphp Delayed Dispatcher');

        $manager = DispatcherRuntimeManager::instance(ConsolePath::basePath());
        $state = $manager->consoleState();

        $this->line('Executed: ' . $state->executed());
        $this->line('Persisted: ' . ($state->persisted() ? 'YES' : 'NO'));
        $this->line('Status: OK');

        return 0;
    }
}
