Fr3nch13/CakePHP Utilities

Arguments
in package

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

Table of Contents

Properties

$argNames  : array<int, string>
Positional argument name map
$args  : array<int, string>
Positional arguments.
$options  : array<string, string|int|bool|null>
Named options

Methods

__construct()  : mixed
Constructor
getArgument()  : string|null
Check if a positional argument exists by name
getArgumentAt()  : string|null
Get positional arguments by index.
getArguments()  : array<int, string>
Get all positional arguments.
getOption()  : string|int|bool|null
Get an option's value or null
getOptions()  : array<string, string|int|bool|null>
Get an array of all the options
hasArgument()  : bool
Check if a positional argument exists by name
hasArgumentAt()  : bool
Check if a positional argument exists
hasOption()  : bool
Check if an option is defined and not null.

Properties

$argNames

Positional argument name map

protected array<int, string> $argNames

$args

Positional arguments.

protected array<int, string> $args

$options

Named options

protected array<string, string|int|bool|null> $options

Methods

__construct()

Constructor

public __construct(array<int, string> $args, array<string, string|int|bool|null> $options, array<int, string> $argNames) : mixed
Parameters
$args : array<int, string>

Positional arguments

$options : array<string, string|int|bool|null>

Named arguments

$argNames : array<int, string>

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

getArgument()

Check if a positional argument exists by name

public getArgument(string $name) : string|null
Parameters
$name : string

The argument name to check.

Return values
string|null

getArgumentAt()

Get positional arguments by index.

public getArgumentAt(int $index) : string|null
Parameters
$index : int

The argument index to access.

Return values
string|null

The argument value or null

getArguments()

Get all positional arguments.

public getArguments() : array<int, string>
Return values
array<int, string>

getOption()

Get an option's value or null

public getOption(string $name) : string|int|bool|null
Parameters
$name : string

The name of the option to check.

Return values
string|int|bool|null

The option value or null.

getOptions()

Get an array of all the options

public getOptions() : array<string, string|int|bool|null>
Return values
array<string, string|int|bool|null>

hasArgument()

Check if a positional argument exists by name

public hasArgument(string $name) : bool
Parameters
$name : string

The argument name to check.

Return values
bool

hasArgumentAt()

Check if a positional argument exists

public hasArgumentAt(int $index) : bool
Parameters
$index : int

The argument index to check.

Return values
bool

hasOption()

Check if an option is defined and not null.

public hasOption(string $name) : bool
Parameters
$name : string

The name of the option to check.

Return values
bool

        
On this page

Search results