Symfony\Component\Console\Application::get PHP Method

get() public method

Returns a registered command by name or alias.
public get ( string $name ) : Command
$name string The command name or alias
return Symfony\Component\Console\Command\Command A Command object
    public function get($name)
    {
        if (!isset($this->commands[$name])) {
            throw new CommandNotFoundException(sprintf('The command "%s" does not exist.', $name));
        }
        $command = $this->commands[$name];
        if ($this->wantHelps) {
            $this->wantHelps = false;
            $helpCommand = $this->get('help');
            $helpCommand->setCommand($command);
            return $helpCommand;
        }
        return $command;
    }

Usage Example

 protected function setUp()
 {
     $application = new Application();
     $application->add(new RepositoryTransferCommand($this->container));
     $command = $application->get(RepositoryTransferCommand::COMMAND_NAME);
     $this->commandTester = new CommandTester($command);
 }
All Usage Examples Of Symfony\Component\Console\Application::get