__construct() public method

构造方法
public __construct ( string $question, mixed $default = null )
$question string 问题
$default mixed 默认答案
Beispiel #1
0
 /**
  * 构造方法
  * @param string $question 问题
  * @param array  $choices  选项
  * @param mixed  $default  默认答案
  */
 public function __construct($question, array $choices, $default = null)
 {
     parent::__construct($question, $default);
     $this->choices = $choices;
     $this->setValidator($this->getDefaultValidator());
     $this->setAutocompleterValues($choices);
 }
Beispiel #2
0
 /**
  * 构造方法
  * @param string $question        问题
  * @param bool   $default         默认答案
  * @param string $trueAnswerRegex 验证正则
  */
 public function __construct($question, $default = true, $trueAnswerRegex = '/^y/i')
 {
     parent::__construct($question, (bool) $default);
     $this->trueAnswerRegex = $trueAnswerRegex;
     $this->setNormalizer($this->getDefaultNormalizer());
 }