class Question

Represents a Question.

Methods

__construct(string $question, mixed $default = null)

No description

string
getQuestion()

Returns the question.

mixed
getDefault()

Returns the default answer.

bool
isHidden()

Returns whether the user response must be hidden.

$this
setHidden(bool $hidden)

Sets whether the user response must be hidden or not.

bool
isHiddenFallback()

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

$this
setHiddenFallback(bool $fallback)

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

iterable|null
getAutocompleterValues()

Gets values for the autocompleter.

$this
setAutocompleterValues(iterable|null $values)

Sets values for the autocompleter.

$this
setValidator(callable $validator = null)

Sets a validator for the question.

callable|null
getValidator()

Gets the validator for the question.

$this
setMaxAttempts(int|null $attempts)

Sets the maximum number of attempts.

int|null
getMaxAttempts()

Gets the maximum number of attempts.

$this
setNormalizer(callable $normalizer)

Sets a normalizer for the response.

callable
getNormalizer()

Gets the normalizer for the response.

isAssoc($array)

No description

Details

at line 37
__construct(string $question, mixed $default = null)

Parameters

string $question The question to ask to the user
mixed $default The default answer to return if the user enters nothing

at line 48
string getQuestion()

Returns the question.

Return Value

string

at line 58
mixed getDefault()

Returns the default answer.

Return Value

mixed

at line 68
bool isHidden()

Returns whether the user response must be hidden.

Return Value

bool

at line 82
$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

at line 98
bool isHiddenFallback()

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

Return Value

bool

at line 110
$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

at line 122
iterable|null getAutocompleterValues()

Gets values for the autocompleter.

Return Value

iterable|null

at line 137
$this setAutocompleterValues(iterable|null $values)

Sets values for the autocompleter.

Parameters

iterable|null $values

Return Value

$this

Exceptions

InvalidArgumentException
LogicException

at line 163
$this setValidator(callable $validator = null)

Sets a validator for the question.

Parameters

callable $validator

Return Value

$this

at line 175
callable|null getValidator()

Gets the validator for the question.

Return Value

callable|null

at line 191
$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

at line 209
int|null getMaxAttempts()

Gets the maximum number of attempts.

Null means an unlimited number of attempts.

Return Value

int|null

at line 223
$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

at line 237
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

at line 242
protected isAssoc($array)

Parameters

$array