Class Symfony\Component\Console\Input\InputDefinition

InheritanceSymfony\Component\Console\Input\InputDefinition

A InputDefinition represents a set of valid command line arguments and options.

Usage:

$definition = new InputDefinition(array(
  new InputArgument('name', InputArgument::REQUIRED),
  new InputOption('foo', 'f', InputOption::VALUE_REQUIRED),
));

Public Methods

Hide inherited methods

MethodDescriptionDefined By
__construct() Constructor. Symfony\Component\Console\Input\InputDefinition
addArgument() Adds an InputArgument object. Symfony\Component\Console\Input\InputDefinition
addArguments() Adds an array of InputArgument objects. Symfony\Component\Console\Input\InputDefinition
addOption() Adds an InputOption object. Symfony\Component\Console\Input\InputDefinition
addOptions() Adds an array of InputOption objects. Symfony\Component\Console\Input\InputDefinition
getArgument() Returns an InputArgument by name or by position. Symfony\Component\Console\Input\InputDefinition
getArgumentCount() Returns the number of InputArguments. Symfony\Component\Console\Input\InputDefinition
getArgumentDefaults() Gets the default values. Symfony\Component\Console\Input\InputDefinition
getArgumentRequiredCount() Returns the number of required InputArguments. Symfony\Component\Console\Input\InputDefinition
getArguments() Gets the array of InputArgument objects. Symfony\Component\Console\Input\InputDefinition
getOption() Returns an InputOption by name. Symfony\Component\Console\Input\InputDefinition
getOptionDefaults() Gets an array of default values. Symfony\Component\Console\Input\InputDefinition
getOptionForShortcut() Gets an InputOption by shortcut. Symfony\Component\Console\Input\InputDefinition
getOptions() Gets the array of InputOption objects. Symfony\Component\Console\Input\InputDefinition
getSynopsis() Gets the synopsis. Symfony\Component\Console\Input\InputDefinition
hasArgument() Returns true if an InputArgument object exists by name or position. Symfony\Component\Console\Input\InputDefinition
hasOption() Returns true if an InputOption object exists by name. Symfony\Component\Console\Input\InputDefinition
hasShortcut() Returns true if an InputOption object exists by shortcut. Symfony\Component\Console\Input\InputDefinition
setArguments() Sets the InputArgument objects. Symfony\Component\Console\Input\InputDefinition
setDefinition() Sets the definition of the input. Symfony\Component\Console\Input\InputDefinition
setOptions() Sets the InputOption objects. Symfony\Component\Console\Input\InputDefinition

Method Details

__construct() public method

Constructor.

public void __construct ( array $definition = [] )
$definition array

An array of InputArgument and InputOption instance

addArgument() public method

Adds an InputArgument object.

public void addArgument ( Symfony\Component\Console\Input\InputArgument $argument )
$argument Symfony\Component\Console\Input\InputArgument

An InputArgument object

throws Symfony\Component\Console\Exception\LogicException

When incorrect argument is given

addArguments() public method

Adds an array of InputArgument objects.

public void addArguments ( $arguments = [] )
$arguments Symfony\Component\Console\Input\InputArgument[]

An array of InputArgument objects

addOption() public method

Adds an InputOption object.

public void addOption ( Symfony\Component\Console\Input\InputOption $option )
$option Symfony\Component\Console\Input\InputOption

An InputOption object

throws Symfony\Component\Console\Exception\LogicException

When option given already exist

addOptions() public method

Adds an array of InputOption objects.

public void addOptions ( $options = [] )
$options Symfony\Component\Console\Input\InputOption[]

An array of InputOption objects

getArgument() public method

Returns an InputArgument by name or by position.

public Symfony\Component\Console\Input\InputArgument getArgument ( $name )
$name string|int

The InputArgument name or position

return Symfony\Component\Console\Input\InputArgument

An InputArgument object

throws Symfony\Component\Console\Exception\InvalidArgumentException

When argument given doesn't exist

getArgumentCount() public method

Returns the number of InputArguments.

public int getArgumentCount ( )
return int

The number of InputArguments

getArgumentDefaults() public method

Gets the default values.

public array getArgumentDefaults ( )
return array

An array of default values

getArgumentRequiredCount() public method

Returns the number of required InputArguments.

public int getArgumentRequiredCount ( )
return int

The number of required InputArguments

getArguments() public method

Gets the array of InputArgument objects.

public Symfony\Component\Console\Input\InputArgument[] getArguments ( )
return Symfony\Component\Console\Input\InputArgument[]

An array of InputArgument objects

getOption() public method

Returns an InputOption by name.

public Symfony\Component\Console\Input\InputOption getOption ( $name )
$name string

The InputOption name

return Symfony\Component\Console\Input\InputOption

A InputOption object

throws Symfony\Component\Console\Exception\InvalidArgumentException

When option given doesn't exist

getOptionDefaults() public method

Gets an array of default values.

public array getOptionDefaults ( )
return array

An array of all default values

getOptionForShortcut() public method

Gets an InputOption by shortcut.

public Symfony\Component\Console\Input\InputOption getOptionForShortcut ( $shortcut )
$shortcut string

The Shortcut name

return Symfony\Component\Console\Input\InputOption

An InputOption object

getOptions() public method

Gets the array of InputOption objects.

public Symfony\Component\Console\Input\InputOption[] getOptions ( )
return Symfony\Component\Console\Input\InputOption[]

An array of InputOption objects

getSynopsis() public method

Gets the synopsis.

public string getSynopsis ( $short false )
$short bool

Whether to return the short version (with options folded) or not

return string

The synopsis

hasArgument() public method

Returns true if an InputArgument object exists by name or position.

public bool hasArgument ( $name )
$name string|int

The InputArgument name or position

return bool

True if the InputArgument object exists, false otherwise

hasOption() public method

Returns true if an InputOption object exists by name.

public bool hasOption ( $name )
$name string

The InputOption name

return bool

True if the InputOption object exists, false otherwise

hasShortcut() public method

Returns true if an InputOption object exists by shortcut.

public bool hasShortcut ( $name )
$name string

The InputOption shortcut

return bool

True if the InputOption object exists, false otherwise

setArguments() public method

Sets the InputArgument objects.

public void setArguments ( $arguments = [] )
$arguments Symfony\Component\Console\Input\InputArgument[]

An array of InputArgument objects

setDefinition() public method

Sets the definition of the input.

public void setDefinition ( array $definition )
$definition array

The definition array

setOptions() public method

Sets the InputOption objects.

public void setOptions ( $options = [] )
$options Symfony\Component\Console\Input\InputOption[]

An array of InputOption objects