<?php
declare(strict_types=1);

namespace PpPhp\Core\Platform\Console\Commands;

use PpPhp\Core\Platform\Console\AbstractCommand;
use PpPhp\Core\Platform\DI\Reflection\ReflectionService;

final class ContainerReflectionCommand extends AbstractCommand
{
    public function name(): string { return 'container:reflection'; }
    public function description(): string { return 'Inspect reflection metadata for a class.'; }

    public function handle(array $arguments = []): int
    {
        $class = $arguments[0] ?? null;

        if (!$class) {
            $this->line('Usage: php platform container:reflection Fully\\Qualified\\ClassName');
            return 1;
        }

        $this->json((new ReflectionService())->inspect($class)->toArray());
        return 0;
    }
}
