<?php
declare(strict_types=1);

namespace PpPhp\Core\Platform\Console\Commands;

use PpPhp\Core\Platform\Console\AbstractCommand;
use PpPhp\Core\Platform\Event\Lifecycle\LifecycleEventManifest;

final class LifecycleListCommand extends AbstractCommand
{
    public function name(): string { return 'lifecycle:list'; }
    public function description(): string { return 'List lifecycle events.'; }

    public function handle(array $arguments = []): int
    {
        $registry = LifecycleEventManifest::registry();
        $this->title('PPphp Lifecycle Events List');

        foreach ($registry->all() as $event) {
            $this->line('[' . strtoupper($event['category']) . '] ' . $event['name']);
        }

        $this->line('Total: ' . $registry->count());
        return 0;
    }
}
