Question\ChoiceQuestion (Component\Console)
Symfony\Component\Console\Question\ChoiceQuestion
class ChoiceQuestion extends Question
Represents a choice question.
Methods
__construct(string $question, array $choices, mixed $default = null) Constructor. | ||
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 |
Question | 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 |
Question | setHiddenFallback(bool $fallback) Sets whether to fallback on non-hidden question if the response can not be hidden. | from Question |
null|array|Traversable | getAutocompleterValues() Gets values for the autocompleter. | from Question |
Question | setAutocompleterValues(null|array|Traversable $values) Sets values for the autocompleter. | from Question |
Question | setValidator(null|callable $validator) Sets a validator for the question. | from Question |
null|callable | getValidator() Gets the validator for the question. | from Question |
Question | setMaxAttempts(null|int $attempts) Sets the maximum number of attempts. | from Question |
null|int | getMaxAttempts() Gets the maximum number of attempts. | from Question |
Question | setNormalizer(callable $normalizer) Sets a normalizer for the response. | from Question |
callable | getNormalizer() Gets the normalizer for the response. | from Question |
array | getChoices() Returns available choices. | |
ChoiceQuestion | setMultiselect(bool $multiselect) Sets multiselect option. | |
string | getPrompt() Gets the prompt for choices. | |
ChoiceQuestion | setPrompt(string $prompt) Sets the prompt for choices. | |
ChoiceQuestion | setErrorMessage(string $errorMessage) Sets the error message for invalid values. |
Details
public __construct(string $question, array $choices, mixed $default = null)
Constructor.
public string getQuestion()
Returns the question.
public mixed getDefault()
Returns the default answer.
public bool isHidden()
Returns whether the user response must be hidden.
public Question setHidden(bool $hidden)
Sets whether the user response must be hidden or not.
public bool isHiddenFallback()
In case the response can not be hidden, whether to fallback on non-hidden question or not.
public Question setHiddenFallback(bool $fallback)
Sets whether to fallback on non-hidden question if the response can not be hidden.
public null|array|Traversable getAutocompleterValues()
Gets values for the autocompleter.
public Question setAutocompleterValues(null|array|Traversable $values)
Sets values for the autocompleter.
public Question setValidator(null|callable $validator)
Sets a validator for the question.
public null|callable getValidator()
Gets the validator for the question.
public Question setMaxAttempts(null|int $attempts)
Sets the maximum number of attempts.
Null means an unlimited number of attempts.
public null|int getMaxAttempts()
Gets the maximum number of attempts.
Null means an unlimited number of attempts.
public Question setNormalizer(callable $normalizer)
Sets a normalizer for the response.
The normalizer can be a callable (a string), a closure or a class implementing __invoke.
public callable getNormalizer()
Gets the normalizer for the response.
The normalizer can ba a callable (a string), a closure or a class implementing __invoke.
public array getChoices()
Returns available choices.
public ChoiceQuestion setMultiselect(bool $multiselect)
Sets multiselect option.
When multiselect is set to true, multiple choices can be answered.
public string getPrompt()
Gets the prompt for choices.
public ChoiceQuestion setPrompt(string $prompt)
Sets the prompt for choices.
public ChoiceQuestion setErrorMessage(string $errorMessage)
Sets the error message for invalid values.
The error message has a string placeholder (%s) for the invalid value.
© 2004–2016 Fabien Potencier
Licensed under the MIT License.
http://api.symfony.com/3.0/Symfony/Component/Console/Question/ChoiceQuestion.html