Skip to content

Latest commit

 

History

History
596 lines (209 loc) · 5.52 KB

ConfirmationQuestion.md

File metadata and controls

596 lines (209 loc) · 5.52 KB

ConfirmationQuestion

Represents a yes/no question.

Properties

trueAnswerRegex

private $trueAnswerRegex

Methods

__construct

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

Parameters:

Parameter Type Description
$question string The question to ask to the user
$default bool The default answer to return, true or false
$trueAnswerRegex string A regex to match the "yes" answer

getDefaultNormalizer

Returns the default answer normalizer.

private getDefaultNormalizer(): callable

Inherited methods

__construct

public __construct(string $question, string|bool|int|float|null $default = null): mixed

Parameters:

Parameter Type Description
$question string The question to ask to the user
$default string|bool|int|float|null The default answer to return if the user enters nothing

getQuestion

Returns the question.

public getQuestion(): string

getDefault

Returns the default answer.

public getDefault(): string|bool|int|float|null

isMultiline

Returns whether the user response accepts newline characters.

public isMultiline(): bool

setMultiline

Sets whether the user response should accept newline characters.

public setMultiline(bool $multiline): $this

Parameters:

Parameter Type Description
$multiline bool

isHidden

Returns whether the user response must be hidden.

public isHidden(): bool

setHidden

Sets whether the user response must be hidden or not.

public setHidden(bool $hidden): $this

Parameters:

Parameter Type Description
$hidden bool

isHiddenFallback

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

public isHiddenFallback(): bool

setHiddenFallback

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

public setHiddenFallback(bool $fallback): $this

Parameters:

Parameter Type Description
$fallback bool

getAutocompleterValues

Gets values for the autocompleter.

public getAutocompleterValues(): iterable|null

setAutocompleterValues

Sets values for the autocompleter.

public setAutocompleterValues(?iterable $values): $this

Parameters:

Parameter Type Description
$values ?iterable

getAutocompleterCallback

Gets the callback function used for the autocompleter.

public getAutocompleterCallback(): ?callable

setAutocompleterCallback

Sets the callback function used for the autocompleter.

public setAutocompleterCallback(callable $callback = null): $this

The callback is passed the user input as argument and should return an iterable of corresponding suggestions.

Parameters:

Parameter Type Description
$callback callable

setValidator

Sets a validator for the question.

public setValidator(callable $validator = null): $this

Parameters:

Parameter Type Description
$validator callable

getValidator

Gets the validator for the question.

public getValidator(): callable|null

setMaxAttempts

Sets the maximum number of attempts.

public setMaxAttempts(?int $attempts): $this

Null means an unlimited number of attempts.

Parameters:

Parameter Type Description
$attempts ?int

getMaxAttempts

Gets the maximum number of attempts.

public getMaxAttempts(): int|null

Null means an unlimited number of attempts.


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:

Parameter Type Description
$normalizer callable

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.


isAssoc

protected isAssoc(array $array): mixed

Parameters:

Parameter Type Description
$array array

isTrimmable

public isTrimmable(): bool

setTrimmable

public setTrimmable(bool $trimmable): $this

Parameters:

Parameter Type Description
$trimmable bool