[Console] Make sure $maxAttempts is an int or null.

This commit is contained in:
Alexander M. Turek 2020-09-06 21:31:28 +02:00 committed by Fabien Potencier
parent ee8fc9cb41
commit 4fcd4916ed

View File

@ -188,8 +188,11 @@ class Question
*/
public function setMaxAttempts($attempts)
{
if (null !== $attempts && $attempts < 1) {
throw new InvalidArgumentException('Maximum number of attempts must be a positive value.');
if (null !== $attempts) {
$attempts = (int) $attempts;
if ($attempts < 1) {
throw new InvalidArgumentException('Maximum number of attempts must be a positive value.');
}
}
$this->attempts = $attempts;