PHP Class think\console\input\Option

Show file Open project: top-think/framework Class Usage Examples

Public Methods

Method Description
__construct ( string $name, string | array $shortcut = null, integer $mode = null, string $description = '', mixed $default = null ) 构造方法
acceptValue ( ) : boolean 是否可以设置值
equals ( Option $option ) : boolean 检查所给选项是否是当前这个
getDefault ( ) : mixed 获取默认值
getDescription ( ) : string 获取描述文字
getName ( ) : string 获取选项名
getShortcut ( ) : string 获取短名称
isArray ( ) : boolean 选项值是否接受数组
isValueOptional ( ) : boolean 是否可选
isValueRequired ( ) : boolean 是否必须
setDefault ( mixed $default = null ) 设置默认值

Method Details

__construct() public method

构造方法
public __construct ( string $name, string | array $shortcut = null, integer $mode = null, string $description = '', mixed $default = null )
$name string 选项名
$shortcut string | array 短名称,多个用|隔开或者使用数组
$mode integer 选项类型(可选类型为 self::VALUE_*)
$description string 描述
$default mixed 默认值 (类型为 self::VALUE_REQUIRED 或者 self::VALUE_NONE 的时候必须为null)

acceptValue() public method

是否可以设置值
public acceptValue ( ) : boolean
return boolean 类型不是 self::VALUE_NONE 的时候返回true,其他均返回false

equals() public method

检查所给选项是否是当前这个
public equals ( Option $option ) : boolean
$option Option
return boolean

getDefault() public method

获取默认值
public getDefault ( ) : mixed
return mixed

getDescription() public method

获取描述文字
public getDescription ( ) : string
return string

getName() public method

获取选项名
public getName ( ) : string
return string

getShortcut() public method

获取短名称
public getShortcut ( ) : string
return string

isArray() public method

选项值是否接受数组
public isArray ( ) : boolean
return boolean 类型是 self::VALUE_IS_ARRAY 的时候返回true,其他均返回false

isValueOptional() public method

是否可选
public isValueOptional ( ) : boolean
return boolean 类型是 self::VALUE_OPTIONAL 的时候返回true,其他均返回false

isValueRequired() public method

是否必须
public isValueRequired ( ) : boolean
return boolean 类型是 self::VALUE_REQUIRED 的时候返回true,其他均返回false

setDefault() public method

设置默认值
public setDefault ( mixed $default = null )
$default mixed 默认值