Input
in package
implements
InputInterface, StreamableInputInterface
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 string -
ArrayInput
: The input is provided as an array
Tags
Table of Contents
Interfaces
- InputInterface
- InputInterface is the interface implemented by all input classes.
- StreamableInputInterface
- StreamableInputInterface is the interface implemented by all input classes that have an input stream.
Properties
- $arguments : mixed
- $definition : mixed
- $interactive : mixed
- $options : mixed
- $stream : resource
Methods
- __construct() : mixed
- bind() : void
- 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, string|bool|int|float|array<string|int, mixed>|null>
- Returns all the given arguments merged with the default values.
- getOption() : mixed
- Returns the option value for a given option name.
- getOptions() : array<string|int, string|bool|int|float|array<string|int, mixed>|null>
- Returns all the given options merged with the default values.
- getStream() : resource
- 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.
- isInteractive() : bool
- Is this input means interactive?
- setArgument() : void
- Sets an argument value by name.
- setInteractive() : void
- Sets the input interactivity.
- setOption() : void
- Sets an option value by name.
- setStream() : void
- Sets the input stream to read from when interacting with the user.
- validate() : void
- Validates the input.
- parse() : void
- Processes command line arguments.
Properties
$arguments
protected
mixed
$arguments
= []
$definition
protected
mixed
$definition
$interactive
protected
mixed
$interactive
= true
$options
protected
mixed
$options
= []
$stream
protected
resource
$stream
Methods
__construct()
public
__construct([InputDefinition|null $definition = null ]) : mixed
Parameters
- $definition : InputDefinition|null = null
bind()
Binds the current Input instance with the given arguments and options.
public
bind(InputDefinition $definition) : void
Parameters
- $definition : InputDefinition
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(string $name) : mixed
Parameters
- $name : string
getArguments()
Returns all the given arguments merged with the default values.
public
getArguments() : array<string|int, string|bool|int|float|array<string|int, mixed>|null>
Return values
array<string|int, string|bool|int|float|array<string|int, mixed>|null>getOption()
Returns the option value for a given option name.
public
getOption(string $name) : mixed
Parameters
- $name : string
getOptions()
Returns all the given options merged with the default values.
public
getOptions() : array<string|int, string|bool|int|float|array<string|int, mixed>|null>
Return values
array<string|int, string|bool|int|float|array<string|int, mixed>|null>getStream()
Returns the input stream.
public
getStream() : resource
Return values
resourcehasArgument()
Returns true if an InputArgument object exists by name or position.
public
hasArgument(string $name) : bool
Parameters
- $name : string
Return values
boolhasOption()
Returns true if an InputOption object exists by name.
public
hasOption(string $name) : bool
Parameters
- $name : string
Return values
boolisInteractive()
Is this input means interactive?
public
isInteractive() : bool
Return values
boolsetArgument()
Sets an argument value by name.
public
setArgument(string $name, mixed $value) : void
Parameters
- $name : string
- $value : mixed
setInteractive()
Sets the input interactivity.
public
setInteractive(bool $interactive) : void
Parameters
- $interactive : bool
setOption()
Sets an option value by name.
public
setOption(string $name, mixed $value) : void
Parameters
- $name : string
- $value : mixed
setStream()
Sets the input stream to read from when interacting with the user.
public
setStream(resource $stream) : void
Parameters
- $stream : resource
validate()
Validates the input.
public
validate() : void
parse()
Processes command line arguments.
protected
abstract parse() : void