You are here

private function ConfirmationQuestion::getDefaultNormalizer in Zircon Profile 8.0

Same name and namespace in other branches
  1. 8 vendor/symfony/console/Question/ConfirmationQuestion.php \Symfony\Component\Console\Question\ConfirmationQuestion::getDefaultNormalizer()

Returns the default answer normalizer.

Return value

callable

1 call to ConfirmationQuestion::getDefaultNormalizer()
ConfirmationQuestion::__construct in vendor/symfony/console/Question/ConfirmationQuestion.php
Constructor.

File

vendor/symfony/console/Question/ConfirmationQuestion.php, line 43

Class

ConfirmationQuestion
Represents a yes/no question.

Namespace

Symfony\Component\Console\Question

Code

private function getDefaultNormalizer() {
  $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;
  };
}