ConfirmationQuestion
extends Question
in package
Represents a yes/no question.
Tags
Table of Contents
Properties
- $attempts : mixed
- $autocompleterValues : mixed
- $default : mixed
- $hidden : mixed
- $hiddenFallback : mixed
- $normalizer : mixed
- $question : mixed
- $trueAnswerRegex : mixed
- $validator : mixed
Methods
- __construct() : mixed
- Constructor.
- getAutocompleterValues() : null|array<string|int, mixed>|Traversable
- Gets values for the autocompleter.
- getDefault() : mixed
- Returns the default answer.
- getMaxAttempts() : null|int
- Gets the maximum number of attempts.
- getNormalizer() : callable
- Gets the normalizer for the response.
- getQuestion() : string
- Returns the question.
- getValidator() : null|callable
- Gets the validator for the question.
- isHidden() : bool
- Returns whether the user response must be hidden.
- isHiddenFallback() : bool
- In case the response can not be hidden, whether to fallback on non-hidden question or not.
- setAutocompleterValues() : $this
- Sets values for the autocompleter.
- setHidden() : $this
- Sets whether the user response must be hidden or not.
- setHiddenFallback() : $this
- Sets whether to fallback on non-hidden question if the response can not be hidden.
- setMaxAttempts() : $this
- Sets the maximum number of attempts.
- setNormalizer() : $this
- Sets a normalizer for the response.
- setValidator() : $this
- Sets a validator for the question.
- isAssoc() : mixed
- getDefaultNormalizer() : callable
- Returns the default answer normalizer.
Properties
$attempts
private
mixed
$attempts
$autocompleterValues
private
mixed
$autocompleterValues
$default
private
mixed
$default
$hidden
private
mixed
$hidden
= false
$hiddenFallback
private
mixed
$hiddenFallback
= true
$normalizer
private
mixed
$normalizer
$question
private
mixed
$question
$trueAnswerRegex
private
mixed
$trueAnswerRegex
$validator
private
mixed
$validator
Methods
__construct()
Constructor.
public
__construct(string $question[, bool $default = true ][, string $trueAnswerRegex = '/^y/i' ]) : mixed
Parameters
- $question : string
-
The question to ask to the user
- $default : bool = true
-
The default answer to return, true or false
- $trueAnswerRegex : string = '/^y/i'
-
A regex to match the "yes" answer
getAutocompleterValues()
Gets values for the autocompleter.
public
getAutocompleterValues() : null|array<string|int, mixed>|Traversable
Return values
null|array<string|int, mixed>|TraversablegetDefault()
Returns the default answer.
public
getDefault() : mixed
getMaxAttempts()
Gets the maximum number of attempts.
public
getMaxAttempts() : null|int
Null means an unlimited number of attempts.
Return values
null|intgetNormalizer()
Gets the normalizer for the response.
public
getNormalizer() : callable
The normalizer can ba a callable (a string), a closure or a class implementing __invoke.
Return values
callablegetQuestion()
Returns the question.
public
getQuestion() : string
Return values
stringgetValidator()
Gets the validator for the question.
public
getValidator() : null|callable
Return values
null|callableisHidden()
Returns whether the user response must be hidden.
public
isHidden() : bool
Return values
boolisHiddenFallback()
In case the response can not be hidden, whether to fallback on non-hidden question or not.
public
isHiddenFallback() : bool
Return values
boolsetAutocompleterValues()
Sets values for the autocompleter.
public
setAutocompleterValues(null|array<string|int, mixed>|Traversable $values) : $this
Parameters
- $values : null|array<string|int, mixed>|Traversable
Tags
Return values
$thissetHidden()
Sets whether the user response must be hidden or not.
public
setHidden(bool $hidden) : $this
Parameters
- $hidden : bool
Tags
Return values
$thissetHiddenFallback()
Sets whether to fallback on non-hidden question if the response can not be hidden.
public
setHiddenFallback(bool $fallback) : $this
Parameters
- $fallback : bool
Return values
$thissetMaxAttempts()
Sets the maximum number of attempts.
public
setMaxAttempts(null|int $attempts) : $this
Null means an unlimited number of attempts.
Parameters
- $attempts : null|int
Tags
Return values
$thissetNormalizer()
Sets a normalizer for the response.
public
setNormalizer(callable $normalizer) : $this
The normalizer can be a callable (a string), a closure or a class implementing __invoke.
Parameters
- $normalizer : callable
Return values
$thissetValidator()
Sets a validator for the question.
public
setValidator([null|callable $validator = null ]) : $this
Parameters
- $validator : null|callable = null
Return values
$thisisAssoc()
protected
isAssoc(mixed $array) : mixed
Parameters
- $array : mixed
getDefaultNormalizer()
Returns the default answer normalizer.
private
getDefaultNormalizer() : callable