function ConfirmationQuestion::getDefaultNormalizer
Returns the default answer normalizer.
1 call to ConfirmationQuestion::getDefaultNormalizer()
- ConfirmationQuestion::__construct in vendor/
symfony/ console/ Question/ ConfirmationQuestion.php
File
-
vendor/
symfony/ console/ Question/ ConfirmationQuestion.php, line 39
Class
- ConfirmationQuestion
- Represents a yes/no question.
Namespace
Symfony\Component\Console\QuestionCode
private function getDefaultNormalizer() : callable {
$default = $this->getDefault();
$regex = $this->trueAnswerRegex;
return function ($answer) use ($default, $regex) {
if (\is_bool($answer)) {
return $answer;
}
$answerIsTrue = (bool) preg_match($regex, $answer);
if (false === $default) {
return $answer && $answerIsTrue;
}
return '' === $answer || $answerIsTrue;
};
}