function QuestionHelper::validateAttempts
Validates an attempt.
Parameters
callable $interviewer A callable that will ask for a question and return the result:
Throws
\Exception In case the max number of attempts has been reached and no valid response has been given
1 call to QuestionHelper::validateAttempts()
- QuestionHelper::ask in vendor/
symfony/ console/ Helper/ QuestionHelper.php - Asks a question to the user.
File
-
vendor/
symfony/ console/ Helper/ QuestionHelper.php, line 462
Class
- QuestionHelper
- The QuestionHelper class provides helpers to interact with the user.
Namespace
Symfony\Component\Console\HelperCode
private function validateAttempts(callable $interviewer, OutputInterface $output, Question $question) : mixed {
$error = null;
$attempts = $question->getMaxAttempts();
while (null === $attempts || $attempts--) {
if (null !== $error) {
$this->writeError($output, $error);
}
try {
return $question->getValidator()($interviewer());
} catch (RuntimeException $e) {
throw $e;
} catch (\Exception $error) {
}
}
throw $error;
}