Class Arguments
Provides an interface for interacting with a command's options and arguments.
Properties summary
-
$argNames
protectedstring[]
-
$args
protectedstring[]
-
$options
protectedarray
Method Summary
-
__construct() publicConstructor
-
getArgument() publicCheck if a positional argument exists by name
-
getArgumentAt() publicGet positional arguments by index.
-
getArguments() publicGet all positional arguments.
-
getOption() publicGet an option's value or null
-
getOptions() publicGet an array of all the options
-
hasArgument() publicCheck if a positional argument exists by name
-
hasArgumentAt() publicCheck if a positional argument exists
-
hasOption() publicCheck 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|nullgetArgumentAt()source public
getArgumentAt( integer $index )
Get positional arguments by index.
Parameters
-
integer
$index
- The argument index to access.
Returns
string|nullThe argument value or null
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|nullThe option value or null.
hasArgument()source public
hasArgument( string $name )
Check if a positional argument exists by name
Parameters
-
string
$name
- The argument name to check.
Returns
booleanhasArgumentAt()source public
hasArgumentAt( integer $index )
Check if a positional argument exists
Parameters
-
integer
$index
- The argument index to check.
Returns
booleanhasOption()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
booleanProperties detail
© 2005–present The Cake Software Foundation, Inc.
Licensed under the MIT License.
CakePHP is a registered trademark of Cake Software Foundation, Inc.
We are not endorsed by or affiliated with CakePHP.
https://api.cakephp.org/3.7/class-Cake.Console.Arguments.html