Webmozart\Console\Api\Config\Config::addArgument PHP Method

addArgument() public method

Read {@link Argument} for a more detailed description of console arguments.
See also: getArguments()
public addArgument ( string $name, integer $flags, string $description = null, mixed $default = null ) : ApplicationConfig | CommandConfig | SubCommandConfig | OptionCommandConfig
$name string The argument name.
$flags integer A bitwise combination of the flag constants in the {@link Argument} class.
$description string A one-line description of the argument.
$default mixed The default value. Must be `null` if the flags contain {@link Argument::REQUIRED}.
return ApplicationConfig | CommandConfig | SubCommandConfig | OptionCommandConfig The current instance.
    public function addArgument($name, $flags = 0, $description = null, $default = null)
    {
        $this->formatBuilder->addArgument(new Argument($name, $flags, $description, $default));
        return $this;
    }

Usage Example

Example #1
0
 public function testAddArgument()
 {
     $this->config->addArgument('argument1', Argument::REQUIRED, 'Description 1');
     $this->config->addArgument('argument2', Argument::OPTIONAL, 'Description 2', 'Default');
     $this->assertEquals(array('argument1' => new Argument('argument1', Argument::REQUIRED, 'Description 1'), 'argument2' => new Argument('argument2', Argument::OPTIONAL, 'Description 2', 'Default')), $this->config->getArguments());
 }