On this page
Class Arguments
Provides an interface for interacting with a command's options and arguments.
Property Summary
Method Summary
__construct() public
Constructor
getArgument() public
Check if a positional argument exists by name
getArgumentAt() public
Get positional arguments by index.
getArguments() public
Get all positional arguments.
getOption() public
Get an option's value or null
getOptions() public
Get an array of all the options
hasArgument() public
Check if a positional argument exists by name
hasArgumentAt() public
Check if a positional argument exists
hasOption() public
Check if an option is defined and not null.
Method Detail
__construct() public
__construct(array<int, string> $args, array<string, string|int|bool|null> $options, array<int, string> $argNames)
Constructor
Parameters
array<int, string>
$args-
Positional arguments
array<string, string|int|bool|null>
$options-
Named arguments
array<int, string>
$argNames-
List of argument names. Order is expected to be the same as $args.
getArgument() public
getArgument(string $name): string|null
Check if a positional argument exists by name
Parameters
string
$name-
The argument name to check.
Returns
string|null
getArgumentAt() public
getArgumentAt(int $index): string|null
Get positional arguments by index.
Parameters
int
$index-
The argument index to access.
Returns
string|null
getArguments() public
getArguments(): array<int, string>
Get all positional arguments.
Returns
array<int, string>
getOption() public
getOption(string $name): string|int|bool|null
Get an option's value or null
Parameters
string
$name-
The name of the option to check.
Returns
string|int|bool|null
getOptions() public
getOptions(): array<string, string|int|bool|null>
Get an array of all the options
Returns
array<string, string|int|bool|null>
hasArgument() public
hasArgument(string $name): bool
Check if a positional argument exists by name
Parameters
string
$name-
The argument name to check.
Returns
bool
hasArgumentAt() public
hasArgumentAt(int $index): bool
Check if a positional argument exists
Parameters
int
$index-
The argument index to check.
Returns
bool
hasOption() public
hasOption(string $name): bool
Check if an option is defined and not null.
Parameters
string
$name-
The name of the option to check.
Returns
bool
Property Detail
$argNames protected
Positional argument name map
Type
array<int, string>
$args protected
Positional arguments.
Type
array<int, string>
$options protected
Named options
Type
array<string, string|int|bool|null>
© 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/4.4/class-Cake.Console.Arguments.html