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

Public Member Functions

 __construct ($name, $shortcut=null, $mode=null, $description= '', $default=null)
 
 getShortcut ()
 
 getName ()
 
 acceptValue ()
 
 isValueRequired ()
 
 isValueOptional ()
 
 isArray ()
 
 setDefault ($default=null)
 
 getDefault ()
 
 getDescription ()
 
 equals (InputOption $option)
 

Public Attributes

const VALUE_NONE = 1
 
const VALUE_REQUIRED = 2
 
const VALUE_OPTIONAL = 4
 
const VALUE_IS_ARRAY = 8
 

Private Attributes

 $name
 
 $shortcut
 
 $mode
 
 $default
 
 $description
 

Detailed Description

Represents a command line option.

Author
Fabien Potencier fabie.nosp@m.n@sy.nosp@m.mfony.nosp@m..com

Definition at line 21 of file InputOption.php.

Constructor & Destructor Documentation

__construct (   $name,
  $shortcut = null,
  $mode = null,
  $description = '',
  $default = null 
)

Constructor.

Parameters
string$nameThe option name
string | array$shortcutThe shortcuts, can be null, a string of shortcuts delimited by | or an array of shortcuts
int$modeThe option mode: One of the VALUE_* constants
string$descriptionA description text
mixed$defaultThe default value (must be null for self::VALUE_REQUIRED or self::VALUE_NONE)
Exceptions
\InvalidArgumentExceptionIf option mode is invalid or incompatible

Definition at line 47 of file InputOption.php.

References InputOption\$default, InputOption\$description, InputOption\$mode, InputOption\$name, InputOption\$shortcut, InputOption\acceptValue(), elseif, InputOption\isArray(), and InputOption\setDefault().

Member Function Documentation

acceptValue ( )

Returns true if the option accepts a value.

Returns
bool true if value mode is not self::VALUE_NONE, false otherwise

Definition at line 117 of file InputOption.php.

References InputOption\isValueOptional(), and InputOption\isValueRequired().

Referenced by InputOption\__construct(), MarkdownDescriptor\describeInputOption(), TextDescriptor\describeInputOption(), JsonDescriptor\getInputOptionData(), XmlDescriptor\getInputOptionDocument(), and InputOption\setDefault().

equals ( InputOption  $option)

Checks whether the given option equals this one.

Parameters
InputOption$optionoption to compare
Returns
bool

Definition at line 203 of file InputOption.php.

References InputOption\getDefault(), InputOption\getName(), InputOption\getShortcut(), InputOption\isArray(), InputOption\isValueOptional(), and InputOption\isValueRequired().

Referenced by InputDefinition\addOption().

getDefault ( )
getDescription ( )

Returns the description text.

Returns
string The description text

Definition at line 191 of file InputOption.php.

References InputOption\$description.

Referenced by MarkdownDescriptor\describeInputOption(), TextDescriptor\describeInputOption(), JsonDescriptor\getInputOptionData(), and XmlDescriptor\getInputOptionDocument().

getName ( )
getShortcut ( )
isArray ( )

Returns true if the option can take multiple values.

Returns
bool true if mode is self::VALUE_IS_ARRAY, false otherwise

Definition at line 147 of file InputOption.php.

References InputOption\$mode.

Referenced by InputOption\__construct(), MarkdownDescriptor\describeInputOption(), TextDescriptor\describeInputOption(), InputOption\equals(), JsonDescriptor\getInputOptionData(), XmlDescriptor\getInputOptionDocument(), and InputOption\setDefault().

isValueOptional ( )

Returns true if the option takes an optional value.

Returns
bool true if value mode is self::VALUE_OPTIONAL, false otherwise

Definition at line 137 of file InputOption.php.

References InputOption\$mode.

Referenced by InputOption\acceptValue(), TextDescriptor\describeInputOption(), and InputOption\equals().

isValueRequired ( )

Returns true if the option requires a value.

Returns
bool true if value mode is self::VALUE_REQUIRED, false otherwise

Definition at line 127 of file InputOption.php.

References InputOption\$mode.

Referenced by InputOption\acceptValue(), MarkdownDescriptor\describeInputOption(), InputOption\equals(), JsonDescriptor\getInputOptionData(), and XmlDescriptor\getInputOptionDocument().

setDefault (   $default = null)

Sets the default value.

Parameters
mixed$defaultThe default value
Exceptions
\LogicExceptionWhen incorrect default value is given

Definition at line 159 of file InputOption.php.

References InputOption\$default, InputOption\acceptValue(), elseif, and InputOption\isArray().

Referenced by InputOption\__construct().

Member Data Documentation

$default
private
$description
private

Definition at line 32 of file InputOption.php.

Referenced by InputOption\__construct(), and InputOption\getDescription().

$mode
private
$name
private

Definition at line 28 of file InputOption.php.

Referenced by InputOption\__construct(), and InputOption\getName().

$shortcut
private

Definition at line 29 of file InputOption.php.

Referenced by InputOption\__construct(), and InputOption\getShortcut().

const VALUE_IS_ARRAY = 8
const VALUE_NONE = 1
const VALUE_OPTIONAL = 4
const VALUE_REQUIRED = 2