PHP Class GetOptionKit\Option

ファイルを表示 Open project: c9s/getoptionkit Class Usage Examples

Public Properties

Property Type Description
$defaultValue
$desc the description of this option
$filter The filter closure of the option value.
$flag
$incremental
$isa * name for the value place holder, for printing
$isaOption
$key The option key
$long
$multiple
$optional
$required
$short
$suggestions
$type
$validValues
$validator
$value * key to store values
$valueName

Protected Properties

Property Type Description
$trigger trigger callback after value is set.

Public Methods

Method Description
__construct ( $spec )
__toString ( )
defaultValue ( $value )
desc ( $desc )
filter ( $cb ) Set up a filter function for the option value.
flag ( )
getId ( ) * get the option key for result key mapping.
getSuggestions ( ) : string[] Return suggestions.
getTypeClass ( )
getValidValues ( ) : string[] Return valud values array.
getValue ( )
increaseValue ( ) This method is for incremental option.
incremental ( ) To make -v, -vv, -vvv works.
isFlag ( )
isIncremental ( )
isMultiple ( )
isOptional ( )
isRequired ( )
isType ( $type )
isTypeNumber ( )
isa ( string $type, mixed $option = null ) Value Type Setters.
multiple ( )
optional ( )
pushValue ( $value ) push option value, when the option accept multiple values.
renderReadableSpec ( string $renderHint = true ) get readable spec for printing.
renderValueHint ( )
required ( )
setValue ( $value ) * set option value
suggestions ( $suggestions ) Assign suggestions.
testValue ( $value )
trigger ( callable $trigger )
validValues ( $values ) Assign validValues to member value.
validate ( $value )
validator ( $cb )
valueName ( $name ) valueName is for option value hinting:.

Protected Methods

Method Description
_preprocessValue ( $value )
callTrigger ( )
initFromSpecString ( string $specString ) Build spec attributes from spec string.

Method Details

__construct() public method

public __construct ( $spec )

__toString() public method

public __toString ( )

_preprocessValue() protected method

protected _preprocessValue ( $value )

callTrigger() protected method

protected callTrigger ( )

defaultValue() public method

public defaultValue ( $value )

desc() public method

public desc ( $desc )

filter() public method

todo: add "callable" type hint later.
public filter ( $cb )

flag() public method

public flag ( )

getId() public method

* get the option key for result key mapping.
public getId ( )

getSuggestions() public method

Return suggestions.
public getSuggestions ( ) : string[]
return string[] or nil

getTypeClass() public method

public getTypeClass ( )

getValidValues() public method

Return valud values array.
public getValidValues ( ) : string[]
return string[] or nil

getValue() public method

public getValue ( )

increaseValue() public method

This method is for incremental option.
public increaseValue ( )

incremental() public method

To make -v, -vv, -vvv works.
public incremental ( )

initFromSpecString() protected method

Build spec attributes from spec string.
protected initFromSpecString ( string $specString )
$specString string

isFlag() public method

public isFlag ( )

isIncremental() public method

public isIncremental ( )

isMultiple() public method

public isMultiple ( )

isOptional() public method

public isOptional ( )

isRequired() public method

public isRequired ( )

isType() public method

public isType ( $type )

isTypeNumber() public method

public isTypeNumber ( )

isa() public method

Value Type Setters.
public isa ( string $type, mixed $option = null )
$type string the value type, valid values are 'number', 'string', 'file', 'boolean', you can also use your own value type name.
$option mixed option(s) for value type class (optionnal)

multiple() public method

public multiple ( )

optional() public method

public optional ( )

pushValue() public method

push option value, when the option accept multiple values.
public pushValue ( $value )

renderReadableSpec() public method

get readable spec for printing.
public renderReadableSpec ( string $renderHint = true )
$renderHint string render also value hint

renderValueHint() public method

public renderValueHint ( )

required() public method

public required ( )

setValue() public method

* set option value
public setValue ( $value )

suggestions() public method

Assign suggestions.
public suggestions ( $suggestions )

testValue() public method

public testValue ( $value )

trigger() public method

public trigger ( callable $trigger )
$trigger callable

validValues() public method

Assign validValues to member value.
public validValues ( $values )

validate() public method

public validate ( $value )

validator() public method

public validator ( $cb )

valueName() public method

--name=
public valueName ( $name )

Property Details

$defaultValue public_oe property

public $defaultValue

$desc public_oe property

the description of this option
public $desc

$filter public_oe property

The filter closure of the option value.
public $filter

$flag public_oe property

public $flag

$incremental public_oe property

public $incremental

$isa public_oe property

* name for the value place holder, for printing
public $isa

$isaOption public_oe property

public $isaOption

$key public_oe property

The option key
public $key

$long public_oe property

public $long

$multiple public_oe property

public $multiple

$optional public_oe property

public $optional

$required public_oe property

public $required

$short public_oe property

public $short

$suggestions public_oe property

public $suggestions

$trigger protected_oe property

trigger callback after value is set.
protected $trigger

$type public_oe property

public $type

$validValues public_oe property

public $validValues

$validator public_oe property

public $validator

$value public_oe property

* key to store values
public $value

$valueName public_oe property

public $valueName