class Option (View source)

The cli option class.

Constants

IS_GLOBAL

IS_PRIVATE

Methods

__construct(mixed $aliases, mixed $default = null, string $description = null, boolean $global = false)

Class Constructor.

setAliases(string $alias)

Alias setter.

array
getAliases()

Alias getter.

boolean
hasAlias(string $alias)

Has alias.

alias(string $alias)

Add a new alias.

defaultValue(mixed $default)

Default value getter.

string
getDefaultValue()

Default value getter.

description(string $description)

Description setter.

string
getDescription()

Description getter.

setName(string $name)

Name setter.

string
getName()

Name getter.

getIO()

Get Cli Input object.

setIO(IOInterface $io)

Set Cli Input object.

mixed
getValue()

Get the value of this option which sent from command line.

bool
isGlobal()

Is this a global option?

setGlobal(boolean $global)

Set this option is global or not.

Details

at line line 99
__construct(mixed $aliases, mixed $default = null, string $description = null, boolean $global = false)

Class Constructor.

Parameters

mixed $aliases The option name. Can be a string, an array or an object. If we use array, the first element will be option name, others will be alias.
mixed $default The default value when we get a non-exists option.
string $description The option description.
boolean $global True is a global option.

at line line 124
Option setAliases(string $alias)

Alias setter.

Parameters

string $alias The option alias.

Return Value

Option Return this object to support chaining.

at line line 138
array getAliases()

Alias getter.

Return Value

array The option alias.

at line line 152
boolean hasAlias(string $alias)

Has alias.

Parameters

string $alias The option alias to find.

Return Value

boolean

at line line 169
Option alias(string $alias)

Add a new alias.

Parameters

string $alias The alias name.

Return Value

Option

at line line 185
Option defaultValue(mixed $default)

Default value getter.

Parameters

mixed $default The default value.

Return Value

Option Return this object to support chaining.

at line line 199
string getDefaultValue()

Default value getter.

Return Value

string The default value.

at line line 213
Option description(string $description)

Description setter.

Parameters

string $description The description.

Return Value

Option Return this object to support chaining.

at line line 227
string getDescription()

Description getter.

Return Value

string The description.

at line line 241
Option setName(string $name)

Name setter.

Parameters

string $name Name of this option.

Return Value

Option Return this object to support chaining.

at line line 255
string getName()

Name getter.

Return Value

string Name of this option.

at line line 267
IOInterface getIO()

Get Cli Input object.

Return Value

IOInterface The Cli IO object.

at line line 286
Option setIO(IOInterface $io)

Set Cli Input object.

Parameters

IOInterface $io The Cli IO object.

Return Value

Option Return this object to support chaining.

at line line 300
mixed getValue()

Get the value of this option which sent from command line.

Return Value

mixed The value of this option.

at line line 329
bool isGlobal()

Is this a global option?

Return Value

bool True is a global option.

at line line 343
Option setGlobal(boolean $global)

Set this option is global or not.

Parameters

boolean $global True is a global option.

Return Value

Option Return this object to support chaining.