TYPO3  7.6
Public Member Functions | Private Member Functions | Private Attributes | List of all members
InputDefinition Class Reference

Public Member Functions

 __construct (array $definition=array())
 
 setDefinition (array $definition)
 
 setArguments ($arguments=array())
 
 addArguments ($arguments=array())
 
 addArgument (InputArgument $argument)
 
 getArgument ($name)
 
 hasArgument ($name)
 
 getArguments ()
 
 getArgumentCount ()
 
 getArgumentRequiredCount ()
 
 getArgumentDefaults ()
 
 setOptions ($options=array())
 
 addOptions ($options=array())
 
 addOption (InputOption $option)
 
 getOption ($name)
 
 hasOption ($name)
 
 getOptions ()
 
 hasShortcut ($name)
 
 getOptionForShortcut ($shortcut)
 
 getOptionDefaults ()
 
 getSynopsis ($short=false)
 
 asText ()
 
 asXml ($asDom=false)
 

Private Member Functions

 shortcutToName ($shortcut)
 

Private Attributes

 $arguments
 
 $requiredCount
 
 $hasAnArrayArgument = false
 
 $hasOptional
 
 $options
 
 $shortcuts
 

Detailed Description

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),
));
Author
Fabien Potencier fabie.nosp@m.n@sy.nosp@m.mfony.nosp@m..com

Definition at line 32 of file InputDefinition.php.

Constructor & Destructor Documentation

__construct ( array  $definition = array())

Constructor.

Parameters
array$definitionAn array of InputArgument and InputOption instance

Definition at line 48 of file InputDefinition.php.

References InputDefinition\setDefinition().

Member Function Documentation

addArgument ( InputArgument  $argument)

Adds an InputArgument object.

Parameters
InputArgument$argumentAn InputArgument object
Exceptions
\LogicExceptionWhen incorrect argument is given

Definition at line 117 of file InputDefinition.php.

References InputDefinition\$hasOptional, InputDefinition\$requiredCount, InputArgument\getName(), InputArgument\isArray(), and InputArgument\isRequired().

Referenced by InputDefinition\addArguments().

addArguments (   $arguments = array())

Adds an array of InputArgument objects.

Parameters
InputArgument[]$arguments An array of InputArgument objects

Definition at line 99 of file InputDefinition.php.

References InputDefinition\$arguments, and InputDefinition\addArgument().

Referenced by InputDefinition\setArguments().

addOption ( InputOption  $option)

Adds an InputOption object.

Parameters
InputOption$optionAn InputOption object
Exceptions
\LogicExceptionWhen option given already exist

Definition at line 266 of file InputDefinition.php.

References InputOption\equals(), InputOption\getName(), and InputOption\getShortcut().

Referenced by InputDefinition\addOptions().

addOptions (   $options = array())

Adds an array of InputOption objects.

Parameters
InputOption[]$options An array of InputOption objects

Definition at line 250 of file InputDefinition.php.

References InputDefinition\$options, and InputDefinition\addOption().

Referenced by InputDefinition\setOptions().

asText ( )

Returns a textual representation of the InputDefinition.

Returns
string A string representing the InputDefinition
Deprecated:
since version 2.3, to be removed in 3.0.

Definition at line 450 of file InputDefinition.php.

References OutputInterface\VERBOSITY_NORMAL.

asXml (   $asDom = false)

Returns an XML representation of the InputDefinition.

Parameters
bool$asDomWhether to return a DOM or an XML string
Returns
string| An XML string representing the InputDefinition
Deprecated:
since version 2.3, to be removed in 3.0.

Definition at line 470 of file InputDefinition.php.

getArgument (   $name)

Returns an InputArgument by name or by position.

Parameters
string | int$nameThe InputArgument name or position
Returns
InputArgument An InputArgument object
Exceptions
\InvalidArgumentExceptionWhen argument given doesn't exist

Definition at line 155 of file InputDefinition.php.

References InputDefinition\$arguments, and InputDefinition\hasArgument().

getArgumentCount ( )

Returns the number of InputArguments.

Returns
int The number of InputArguments

Definition at line 199 of file InputDefinition.php.

getArgumentDefaults ( )

Gets the default values.

Returns
array An array of default values

Definition at line 219 of file InputDefinition.php.

getArgumentRequiredCount ( )

Returns the number of required InputArguments.

Returns
int The number of required InputArguments

Definition at line 209 of file InputDefinition.php.

References InputDefinition\$requiredCount.

getArguments ( )
getOption (   $name)

Returns an InputOption by name.

Parameters
string$nameThe InputOption name
Returns
InputOption A InputOption object
Exceptions
\InvalidArgumentExceptionWhen option given doesn't exist

Definition at line 299 of file InputDefinition.php.

References InputDefinition\hasOption().

Referenced by InputDefinition\getOptionForShortcut().

getOptionDefaults ( )

Gets an array of default values.

Returns
array An array of all default values

Definition at line 363 of file InputDefinition.php.

getOptionForShortcut (   $shortcut)

Gets an InputOption by shortcut.

Parameters
string$shortcutthe Shortcut name
Returns
InputOption An InputOption object

Definition at line 353 of file InputDefinition.php.

References InputDefinition\getOption(), and InputDefinition\shortcutToName().

getOptions ( )
getSynopsis (   $short = false)

Gets the synopsis.

Parameters
bool$shortWhether to return the short version (with options folded) or not
Returns
string The synopsis

Definition at line 398 of file InputDefinition.php.

References elseif, InputDefinition\getArguments(), and InputDefinition\getOptions().

Referenced by InputDefinitionTest\testGetSynopsis().

hasArgument (   $name)

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

Parameters
string | int$nameThe InputArgument name or position
Returns
bool true if the InputArgument object exists, false otherwise

Definition at line 175 of file InputDefinition.php.

References InputDefinition\$arguments.

Referenced by InputDefinition\getArgument().

hasOption (   $name)

Returns true if an InputOption object exists by name.

Parameters
string$nameThe InputOption name
Returns
bool true if the InputOption object exists, false otherwise

Definition at line 317 of file InputDefinition.php.

Referenced by InputDefinition\getOption().

hasShortcut (   $name)

Returns true if an InputOption object exists by shortcut.

Parameters
string$nameThe InputOption shortcut
Returns
bool true if the InputOption object exists, false otherwise

Definition at line 341 of file InputDefinition.php.

setArguments (   $arguments = array())

Sets the InputArgument objects.

Parameters
InputArgument[]$arguments An array of InputArgument objects

Definition at line 83 of file InputDefinition.php.

References InputDefinition\$arguments, and InputDefinition\addArguments().

Referenced by InputDefinition\setDefinition().

setDefinition ( array  $definition)

Sets the definition of the input.

Parameters
array$definitionThe definition array

Definition at line 60 of file InputDefinition.php.

References InputDefinition\$arguments, InputDefinition\$options, InputDefinition\setArguments(), and InputDefinition\setOptions().

Referenced by InputDefinition\__construct().

setOptions (   $options = array())

Sets the InputOption objects.

Parameters
InputOption[]$options An array of InputOption objects

Definition at line 236 of file InputDefinition.php.

References InputDefinition\$options, and InputDefinition\addOptions().

Referenced by InputDefinition\setDefinition().

shortcutToName (   $shortcut)
private

Returns the InputOption name given a shortcut.

Parameters
string$shortcutThe shortcut
Returns
string The InputOption name
Exceptions
\InvalidArgumentExceptionWhen option given does not exist

Definition at line 382 of file InputDefinition.php.

Referenced by InputDefinition\getOptionForShortcut().

Member Data Documentation

$arguments
private
$hasAnArrayArgument = false
private

Definition at line 36 of file InputDefinition.php.

$hasOptional
private

Definition at line 37 of file InputDefinition.php.

Referenced by InputDefinition\addArgument().

$options
private
$requiredCount
private
$shortcuts
private

Definition at line 39 of file InputDefinition.php.