\Cake\ConsoleArguments

Provides an interface for interacting with a command's options and arguments.

Summary

Methods
Properties
Constants
__construct()
getArguments()
getArgumentAt()
hasArgumentAt()
hasArgument()
getArgument()
getOptions()
getOption()
hasOption()
No public properties found
No constants found
No protected methods found
$argNames
$args
$options
N/A
No private methods found
No private properties found
N/A

Properties

$argNames

$argNames : array<mixed,string>

Positional argument name map

Type

array<mixed,string>

$args

$args : array<mixed,string>

Positional arguments.

Type

array<mixed,string>

$options

$options : array

Named options

Type

array

Methods

__construct()

__construct(array<mixed,string>  $args, array  $options, array<mixed,string>  $argNames) 

Constructor

Parameters

array<mixed,string> $args

Positional arguments

array $options

Named arguments

array<mixed,string> $argNames

List of argument names. Order is expected to be the same as $args.

getArguments()

getArguments() : array<mixed,string>

Get all positional arguments.

Returns

array<mixed,string>

getArgumentAt()

getArgumentAt(integer  $index) : string|null

Get positional arguments by index.

Parameters

integer $index

The argument index to access.

Returns

string|null —

The argument value or null

hasArgumentAt()

hasArgumentAt(integer  $index) : boolean

Check if a positional argument exists

Parameters

integer $index

The argument index to check.

Returns

boolean

hasArgument()

hasArgument(string  $name) : boolean

Check if a positional argument exists by name

Parameters

string $name

The argument name to check.

Returns

boolean

getArgument()

getArgument(string  $name) : string|null

Check if a positional argument exists by name

Parameters

string $name

The argument name to check.

Returns

string|null

getOptions()

getOptions() : array

Get an array of all the options

Returns

array

getOption()

getOption(string  $name) : string|integer|boolean|null

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.

hasOption()

hasOption(string  $name) : boolean

Check if an option is defined and not null.

Parameters

string $name

The name of the option to check.

Returns

boolean