Skip to main content
Drupal API
User account menu
  • Log in

Breadcrumb

  1. Drupal Core 11.1.x
  2. Question.php

function Question::setMaxAttempts

Sets the maximum number of attempts.

Null means an unlimited number of attempts.

Return value

$this

Throws

InvalidArgumentException in case the number of attempts is invalid

File

vendor/symfony/console/Question/Question.php, line 216

Class

Question
Represents a Question.

Namespace

Symfony\Component\Console\Question

Code

public function setMaxAttempts(?int $attempts) : static {
    if (null !== $attempts && $attempts < 1) {
        throw new InvalidArgumentException('Maximum number of attempts must be a positive value.');
    }
    $this->attempts = $attempts;
    return $this;
}

API Navigation

  • Drupal Core 11.1.x
  • Topics
  • Classes
  • Functions
  • Constants
  • Globals
  • Files
  • Namespaces
  • Deprecated
  • Services
RSS feed
Powered by Drupal