PHP Class GetOptionKit\Option

Afficher le fichier Open project: c9s/getoptionkit Class Usage Examples

Méthodes publiques

Свойство 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

Свойство Type Description
$trigger trigger callback after value is set.

Méthodes publiques

Méthode 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:.

Méthodes protégées

Méthode Description
_preprocessValue ( $value )
callTrigger ( )
initFromSpecString ( string $specString ) Build spec attributes from spec string.

Method Details

__construct() public méthode

public __construct ( $spec )

__toString() public méthode

public __toString ( )

_preprocessValue() protected méthode

protected _preprocessValue ( $value )

callTrigger() protected méthode

protected callTrigger ( )

defaultValue() public méthode

public defaultValue ( $value )

desc() public méthode

public desc ( $desc )

filter() public méthode

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

flag() public méthode

public flag ( )

getId() public méthode

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

getSuggestions() public méthode

Return suggestions.
public getSuggestions ( ) : string[]
Résultat string[] or nil

getTypeClass() public méthode

public getTypeClass ( )

getValidValues() public méthode

Return valud values array.
public getValidValues ( ) : string[]
Résultat string[] or nil

getValue() public méthode

public getValue ( )

increaseValue() public méthode

This method is for incremental option.
public increaseValue ( )

incremental() public méthode

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

initFromSpecString() protected méthode

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

isFlag() public méthode

public isFlag ( )

isIncremental() public méthode

public isIncremental ( )

isMultiple() public méthode

public isMultiple ( )

isOptional() public méthode

public isOptional ( )

isRequired() public méthode

public isRequired ( )

isType() public méthode

public isType ( $type )

isTypeNumber() public méthode

public isTypeNumber ( )

isa() public méthode

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 méthode

public multiple ( )

optional() public méthode

public optional ( )

pushValue() public méthode

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

renderReadableSpec() public méthode

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

renderValueHint() public méthode

public renderValueHint ( )

required() public méthode

public required ( )

setValue() public méthode

* set option value
public setValue ( $value )

suggestions() public méthode

Assign suggestions.
public suggestions ( $suggestions )

testValue() public méthode

public testValue ( $value )

trigger() public méthode

public trigger ( callable $trigger )
$trigger callable

validValues() public méthode

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

validate() public méthode

public validate ( $value )

validator() public méthode

public validator ( $cb )

valueName() public méthode

--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