<?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 DispatcherStatsCommand extends AbstractCommand
{
    public function name(): string { return 'dispatcher:stats'; }
    public function description(): string { return 'PPphp Dispatcher Stats'; }

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

        $manager = DispatcherRuntimeManager::instance(ConsolePath::basePath());

        foreach ($manager->consoleState()->statistics() as $key => $value) {
            $this->line($key . ': ' . $value);
        }

        return 0;
    }
}
