class InputOption

Represents a command line option.

Constants

VALUE_NONE

VALUE_REQUIRED

VALUE_OPTIONAL

VALUE_IS_ARRAY

Methods

__construct(string $name, string|array|null $shortcut = null, int|null $mode = null, string $description = '', string|string[]|int|bool|null $default = null)

No description

string|null
getShortcut()

Returns the option shortcut.

string
getName()

Returns the option name.

bool
acceptValue()

Returns true if the option accepts a value.

bool
isValueRequired()

Returns true if the option requires a value.

bool
isValueOptional()

Returns true if the option takes an optional value.

bool
isArray()

Returns true if the option can take multiple values.

setDefault(string|string[]|int|bool|null $default = null)

Sets the default value.

string|string[]|int|bool|null
getDefault()

Returns the default value.

string
getDescription()

Returns the description text.

bool
equals(InputOption $option)

Checks whether the given option equals this one.

Details

at line 44
__construct(string $name, string|array|null $shortcut = null, int|null $mode = null, string $description = '', string|string[]|int|bool|null $default = null)

Parameters

string $name The option name
string|array|null $shortcut The shortcuts, can be null, a string of shortcuts delimited by | or an array of shortcuts
int|null $mode The option mode: One of the VALUE_* constants
string $description A description text
string|string[]|int|bool|null $default The default value (must be null for self::VALUE_NONE)

Exceptions

InvalidArgumentException If option mode is invalid or incompatible

at line 94
string|null getShortcut()

Returns the option shortcut.

Return Value

string|null The shortcut

at line 104
string getName()

Returns the option name.

Return Value

string The name

at line 114
bool acceptValue()

Returns true if the option accepts a value.

Return Value

bool true if value mode is not self::VALUE_NONE, false otherwise

at line 124
bool isValueRequired()

Returns true if the option requires a value.

Return Value

bool true if value mode is self::VALUE_REQUIRED, false otherwise

at line 134
bool isValueOptional()

Returns true if the option takes an optional value.

Return Value

bool true if value mode is self::VALUE_OPTIONAL, false otherwise

at line 144
bool isArray()

Returns true if the option can take multiple values.

Return Value

bool true if mode is self::VALUE_IS_ARRAY, false otherwise

at line 156
setDefault(string|string[]|int|bool|null $default = null)

Sets the default value.

Parameters

string|string[]|int|bool|null $default The default value

Exceptions

LogicException When incorrect default value is given

at line 178
string|string[]|int|bool|null getDefault()

Returns the default value.

Return Value

string|string[]|int|bool|null The default value

at line 188
string getDescription()

Returns the description text.

Return Value

string The description text

at line 198
bool equals(InputOption $option)

Checks whether the given option equals this one.

Parameters

InputOption $option

Return Value

bool