W3cubDocs

/Symfony 4.1

ConfirmationQuestion

class ConfirmationQuestion extends Question

Represents a yes/no question.

Methods

__construct(string $question, mixed $default = true, string $trueAnswerRegex = '/^y/i')
string getQuestion()

Returns the question.

from Question
mixed getDefault()

Returns the default answer.

from Question
bool isHidden()

Returns whether the user response must be hidden.

from Question
$this setHidden(bool $hidden)

Sets whether the user response must be hidden or not.

from Question
bool isHiddenFallback()

In case the response can not be hidden, whether to fallback on non-hidden question or not.

from Question
$this setHiddenFallback(bool $fallback)

Sets whether to fallback on non-hidden question if the response can not be hidden.

from Question
iterable|null getAutocompleterValues()

Gets values for the autocompleter.

from Question
$this setAutocompleterValues(iterable|null $values)

Sets values for the autocompleter.

from Question
$this setValidator(callable $validator = null)

Sets a validator for the question.

from Question
callable|null getValidator()

Gets the validator for the question.

from Question
$this setMaxAttempts(int|null $attempts)

Sets the maximum number of attempts.

from Question
int|null getMaxAttempts()

Gets the maximum number of attempts.

from Question
$this setNormalizer(callable $normalizer)

Sets a normalizer for the response.

from Question
callable getNormalizer()

Gets the normalizer for the response.

from Question
isAssoc($array) from Question

Details

__construct(string $question, mixed $default = true, string $trueAnswerRegex = '/^y/i')

Parameters

string $question The question to ask to the user
mixed $default The default answer to return if the user enters nothing
string $trueAnswerRegex A regex to match the "yes" answer

string getQuestion()

Returns the question.

Return Value

string

mixed getDefault()

Returns the default answer.

Return Value

mixed

bool isHidden()

Returns whether the user response must be hidden.

Return Value

bool

$this setHidden(bool $hidden)

Sets whether the user response must be hidden or not.

Parameters

bool $hidden

Return Value

$this

Exceptions

LogicException In case the autocompleter is also used

bool isHiddenFallback()

In case the response can not be hidden, whether to fallback on non-hidden question or not.

Return Value

bool

$this setHiddenFallback(bool $fallback)

Sets whether to fallback on non-hidden question if the response can not be hidden.

Parameters

bool $fallback

Return Value

$this

iterable|null getAutocompleterValues()

Gets values for the autocompleter.

Return Value

iterable|null

$this setAutocompleterValues(iterable|null $values)

Sets values for the autocompleter.

Parameters

iterable|null $values

Return Value

$this

Exceptions

InvalidArgumentException
LogicException

$this setValidator(callable $validator = null)

Sets a validator for the question.

Parameters

callable $validator

Return Value

$this

callable|null getValidator()

Gets the validator for the question.

Return Value

callable|null

$this setMaxAttempts(int|null $attempts)

Sets the maximum number of attempts.

Null means an unlimited number of attempts.

Parameters

int|null $attempts

Return Value

$this

Exceptions

InvalidArgumentException in case the number of attempts is invalid

int|null getMaxAttempts()

Gets the maximum number of attempts.

Null means an unlimited number of attempts.

Return Value

int|null

$this setNormalizer(callable $normalizer)

Sets a normalizer for the response.

The normalizer can be a callable (a string), a closure or a class implementing __invoke.

Parameters

callable $normalizer

Return Value

$this

callable getNormalizer()

Gets the normalizer for the response.

The normalizer can ba a callable (a string), a closure or a class implementing __invoke.

Return Value

callable

protected isAssoc($array)

Parameters

$array

© 2004–2017 Fabien Potencier
Licensed under the MIT License.
https://api.symfony.com/4.1/Symfony/Component/Console/Question/ConfirmationQuestion.html