Class Arguments
Provides an interface for interacting with a command's options and arguments.
Properties summary
-
string[]
Positional argument name map -
string[]
Positional arguments. -
array
Named options
Method Summary
- Constructor
- Check if a positional argument exists by name
- Get positional arguments by index.
- Get all positional arguments.
- Get an option's value or null
- Get an array of all the options
- Check if a positional argument exists by name
- Check if a positional argument exists
- Check if an option is defined and not null.
Method Detail
__construct()source public
__construct( array $args , array $options , array $argNames )
Constructor
Parameters
- array
$args
- Positional arguments
- array
$options
- Named arguments
- array
$argNames
List of argument names. Order is expected to be the same as $args.
getArgument()source public
getArgument( string $name )
Check if a positional argument exists by name
Parameters
- string
$name
- The argument name to check.
Returns
string|null
getArgumentAt()source public
getArgumentAt( integer $index )
Get positional arguments by index.
Parameters
- integer
$index
- The argument index to access.
Returns
string|null
The argument value or null
getArguments()source public
getArguments( )
Get all positional arguments.
Returns
string[]
getOption()source public
getOption( string $name )
Get an option's value or null
Parameters
- string
$name
- The name of the option to check.
Returns
string|integer|boolean|null
The option value or null.
getOptions()source public
getOptions( )
Get an array of all the options
Returns
array
hasArgument()source public
hasArgument( string $name )
Check if a positional argument exists by name
Parameters
- string
$name
- The argument name to check.
Returns
boolean
hasArgumentAt()source public
hasArgumentAt( integer $index )
Check if a positional argument exists
Parameters
- integer
$index
- The argument index to check.
Returns
boolean
hasOption()source public
hasOption( string $name )
Check if an option is defined and not null.
Parameters
- string
$name
- The name of the option to check.
Returns
boolean
Properties detail
protected string[]
Positional argument name map
protected string[]
Positional arguments.
protected array
Named options