Documentation

StrictConfirmationQuestion extends Question
in package

Represents a yes/no question Enforces strict responses rather than non-standard answers counting as default Based on Symfony\Component\Console\Question\ConfirmationQuestion

Tags
author

Theo Tonge theo@theotonge.co.uk

Table of Contents

$attempts  : mixed
$autocompleterValues  : mixed
$default  : mixed
$falseAnswerRegex  : mixed
$hidden  : mixed
$hiddenFallback  : mixed
$normalizer  : mixed
$question  : mixed
$trueAnswerRegex  : mixed
$validator  : mixed
__construct()  : mixed
Constructor.s
getAutocompleterValues()  : iteratable<string|int, mixed>|null
Gets values for the autocompleter.
getDefault()  : mixed
Returns the default answer.
getMaxAttempts()  : int|null
Gets the maximum number of attempts.
getNormalizer()  : callable|null
Gets the normalizer for the response.
getQuestion()  : string
Returns the question.
getValidator()  : callable|null
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.
getDefaultValidator()  : callable
Returns the default answer validator.

Properties

$autocompleterValues

private mixed $autocompleterValues

$hiddenFallback

private mixed $hiddenFallback = true

Methods

__construct()

Constructor.s

public __construct(string $question[, bool $default = true ][, string $trueAnswerRegex = '/^y(?:es)?$/i' ][, string $falseAnswerRegex = '/^no?$/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(?:es)?$/i'

A regex to match the "yes" answer

$falseAnswerRegex : string = '/^no?$/i'

A regex to match the "no" answer

Return values
mixed

getAutocompleterValues()

Gets values for the autocompleter.

public getAutocompleterValues() : iteratable<string|int, mixed>|null
Return values
iteratable<string|int, mixed>|null

getDefault()

Returns the default answer.

public getDefault() : mixed
Return values
mixed

getMaxAttempts()

Gets the maximum number of attempts.

public getMaxAttempts() : int|null

Null means an unlimited number of attempts.

Return values
int|null

getNormalizer()

Gets the normalizer for the response.

public getNormalizer() : callable|null

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

Return values
callable|null

getQuestion()

Returns the question.

public getQuestion() : string
Return values
string

getValidator()

Gets the validator for the question.

public getValidator() : callable|null
Return values
callable|null

isHidden()

Returns whether the user response must be hidden.

public isHidden() : bool
Return values
bool

isHiddenFallback()

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

public isHiddenFallback() : bool
Return values
bool

setAutocompleterValues()

Sets values for the autocompleter.

public setAutocompleterValues(iteratable<string|int, mixed>|null $values) : $this
Parameters
$values : iteratable<string|int, mixed>|null
Tags
throws
InvalidArgumentException
throws
LogicException
Return values
$this

setHidden()

Sets whether the user response must be hidden or not.

public setHidden(bool $hidden) : $this
Parameters
$hidden : bool
Tags
throws
LogicException

In case the autocompleter is also used

Return values
$this

setHiddenFallback()

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
$this

setMaxAttempts()

Sets the maximum number of attempts.

public setMaxAttempts(int|null $attempts) : $this

Null means an unlimited number of attempts.

Parameters
$attempts : int|null
Tags
throws
InvalidArgumentException

in case the number of attempts is invalid

Return values
$this

setNormalizer()

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
$this

setValidator()

Sets a validator for the question.

public setValidator([callable $validator = null ]) : $this
Parameters
$validator : callable = null
Return values
$this

isAssoc()

protected isAssoc(mixed $array) : mixed
Parameters
$array : mixed
Return values
mixed

getDefaultNormalizer()

Returns the default answer normalizer.

private getDefaultNormalizer() : callable
Return values
callable

getDefaultValidator()

Returns the default answer validator.

private getDefaultValidator() : callable
Return values
callable

Search results