<?php
declare(strict_types=1);

namespace PpPhp\Core\Platform\Console\Commands;

use PpPhp\Core\Platform\Console\AbstractCommand;
use PpPhp\Core\Platform\DI\Container;

final class ContainerResolveCommand extends AbstractCommand
{
    public function name(): string { return 'container:resolve'; }
    public function description(): string { return 'Resolve a class through the DI container.'; }

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

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

        $object = (new Container())->get($class);
        $this->line('Resolved: ' . $object::class);
        return 0;
    }
}
