NonStringInput
extends Input
in package
Input is the base class for all concrete Input classes.
Three concrete classes are provided by default:
ArgvInput
: The input comes from the CLI arguments (argv)StringInput
: The input is provided as a stringArrayInput
: The input is provided as an array
Table of Contents
Properties
- $arguments : mixed
- $definition : InputDefinition
- $interactive : mixed
- $options : mixed
- $stream : mixed
Methods
- __construct() : mixed
- Constructor.
- bind() : mixed
- Binds the current Input instance with the given arguments and options.
- escapeToken() : string
- Escapes a token through escapeshellarg if it contains unsafe chars.
- getArgument() : mixed
- Returns the argument value for a given argument name.
- getArguments() : array<string|int, mixed>
- Returns all the given arguments merged with the default values.
- getFirstArgument() : string
- Returns the first argument from the raw parameters (not parsed).
- getOption() : mixed
- Returns the option value for a given option name.
- getOptions() : array<string|int, mixed>
- Returns all the given options merged with the default values.
- getParameterOption() : mixed
- Returns the value of a raw option (not parsed).
- getStream() : resource|null
- Returns the input stream.
- hasArgument() : bool
- Returns true if an InputArgument object exists by name or position.
- hasOption() : bool
- Returns true if an InputOption object exists by name.
- hasParameterOption() : bool
- Returns true if the raw parameters (not parsed) contain a value.
- isInteractive() : bool
- Is this input means interactive?
- parse() : mixed
- Processes command line arguments.
- setArgument() : mixed
- Sets an argument value by name.
- setInteractive() : mixed
- Sets the input interactivity.
- setOption() : mixed
- Sets an option value by name.
- setStream() : mixed
- Sets the input stream to read from when interacting with the user.
- validate() : mixed
- Validates the input.
Properties
$arguments
protected
mixed
$arguments
= array()
$definition
protected
InputDefinition
$definition
$interactive
protected
mixed
$interactive
= true
$options
protected
mixed
$options
= array()
$stream
protected
mixed
$stream
Methods
__construct()
Constructor.
public
__construct([InputDefinition|null $definition = null ]) : mixed
Parameters
- $definition : InputDefinition|null = null
-
A InputDefinition instance
bind()
Binds the current Input instance with the given arguments and options.
public
bind(InputDefinition $definition) : mixed
Parameters
- $definition : InputDefinition
-
A InputDefinition instance
escapeToken()
Escapes a token through escapeshellarg if it contains unsafe chars.
public
escapeToken(string $token) : string
Parameters
- $token : string
Return values
stringgetArgument()
Returns the argument value for a given argument name.
public
getArgument(mixed $name) : mixed
Parameters
- $name : mixed
-
The argument name
Return values
mixed —The argument value
getArguments()
Returns all the given arguments merged with the default values.
public
getArguments() : array<string|int, mixed>
Return values
array<string|int, mixed>getFirstArgument()
Returns the first argument from the raw parameters (not parsed).
public
getFirstArgument() : string
Return values
string —The value of the first argument or null otherwise
getOption()
Returns the option value for a given option name.
public
getOption(mixed $name) : mixed
Parameters
- $name : mixed
-
The option name
Return values
mixed —The option value
getOptions()
Returns all the given options merged with the default values.
public
getOptions() : array<string|int, mixed>
Return values
array<string|int, mixed>getParameterOption()
Returns the value of a raw option (not parsed).
public
getParameterOption(mixed $values[, mixed $default = false ][, mixed $onlyParams = false ]) : mixed
This method is to be used to introspect the input parameters before they have been validated. It must be used carefully.
Parameters
- $values : mixed
-
The value(s) to look for in the raw parameters (can be an array)
- $default : mixed = false
-
The default value to return if no result is found
- $onlyParams : mixed = false
-
Only check real parameters, skip those following an end of options (--) signal
Return values
mixed —The option value
getStream()
Returns the input stream.
public
getStream() : resource|null
Return values
resource|nullhasArgument()
Returns true if an InputArgument object exists by name or position.
public
hasArgument(mixed $name) : bool
Parameters
- $name : mixed
-
The InputArgument name or position
Return values
bool —true if the InputArgument object exists, false otherwise
hasOption()
Returns true if an InputOption object exists by name.
public
hasOption(mixed $name) : bool
Parameters
- $name : mixed
-
The InputOption name
Return values
bool —true if the InputOption object exists, false otherwise
hasParameterOption()
Returns true if the raw parameters (not parsed) contain a value.
public
hasParameterOption(mixed $values[, mixed $onlyParams = false ]) : bool
This method is to be used to introspect the input parameters before they have been validated. It must be used carefully.
Parameters
- $values : mixed
-
The values to look for in the raw parameters (can be an array)
- $onlyParams : mixed = false
-
Only check real parameters, skip those following an end of options (--) signal
Return values
bool —true if the value is contained in the raw parameters
isInteractive()
Is this input means interactive?
public
isInteractive() : bool
Return values
boolparse()
Processes command line arguments.
public
parse() : mixed
setArgument()
Sets an argument value by name.
public
setArgument(mixed $name, mixed $value) : mixed
Parameters
- $name : mixed
-
The argument name
- $value : mixed
-
The argument value
setInteractive()
Sets the input interactivity.
public
setInteractive(mixed $interactive) : mixed
Parameters
- $interactive : mixed
-
If the input should be interactive
setOption()
Sets an option value by name.
public
setOption(mixed $name, mixed $value) : mixed
Parameters
- $name : mixed
-
The option name
- $value : mixed
-
The option value
setStream()
Sets the input stream to read from when interacting with the user.
public
setStream(mixed $stream) : mixed
Parameters
- $stream : mixed
-
The input stream
validate()
Validates the input.
public
validate() : mixed