Webmozart\Console\Api\Args\Format\ArgsFormatBuilder::addCommandName PHP Method

addCommandName() public method

Adds a command name to the built format.
public addCommandName ( CommandName $commandName ) : static
$commandName CommandName The command name to add.
return static The current instance.
    public function addCommandName(CommandName $commandName)
    {
        $this->commandNames[] = $commandName;
        return $this;
    }

Usage Example

 public function testGetDefinitionWithBaseDefinition()
 {
     $this->baseFormatBuilder->addCommandName($server = new CommandName('server'));
     $this->baseFormatBuilder->addArgument($argument1 = new Argument('argument1'));
     $this->baseFormatBuilder->addOption($option1 = new Option('option1'));
     $this->builder = new ArgsFormatBuilder($baseDefinition = $this->baseFormatBuilder->getFormat());
     $this->builder->addCommandName($add = new CommandName('add'));
     $this->builder->addArgument($argument2 = new Argument('argument2'));
     $this->builder->addArgument($argument3 = new Argument('argument3'));
     $this->builder->addOption($option2 = new Option('option2'));
     $this->builder->addOption($option3 = new Option('option3'));
     $definition = $this->builder->getFormat();
     $this->assertSame($baseDefinition, $definition->getBaseFormat());
     // base command names are returned first
     $this->assertSame(array($server, $add), $definition->getCommandNames());
     // base arguments are returned first
     $this->assertSame(array('argument1' => $argument1, 'argument2' => $argument2, 'argument3' => $argument3), $definition->getArguments());
     // base options are returned last
     $this->assertSame(array('option2' => $option2, 'option3' => $option3, 'option1' => $option1), $definition->getOptions());
 }
All Usage Examples Of Webmozart\Console\Api\Args\Format\ArgsFormatBuilder::addCommandName