class PasswordPrompter extends CallbackPrompter (View source)

A password prompter supports hidden input.

Methods

__construct(string $question = null, callable $handler = null, $default = null, IOInterface $io = null)

Constructor.

string
ask(string $msg = '', string $default = null)

Show prompt to ask user.

string
in(string $question = '')

Get a value from standard input.

string
__invoke(string $msg = null, string $default = null)

Proxy to ask method.

getIO()

Method to get property Io

setIO(IOInterface $io)

Method to set property io

setHandler(callable $handler)

Set a callable handler, can be a Closure.

callable
getHandler()

Get callable handler.

setAttemptTimes(int $attempt)

Set attempt number.

setNoValidMessage(string $noValidMessage)

Set message when validate fail.

failToClose(boolean $failToClose = null, string $message = '')

If validate fail, whether close application or not.

Details

__construct(string $question = null, callable $handler = null, $default = null, IOInterface $io = null)

Constructor.

Parameters

string $question The question you want to ask.
callable $handler The callback handler.
$default $default The default value.
IOInterface $io The input object.

at line line 95
string ask(string $msg = '', string $default = null)

Show prompt to ask user.

Parameters

string $msg Question.
string $default Default value.

Return Value

string The value that use input.

at line line 111
string in(string $question = '')

Get a value from standard input.

Parameters

string $question The question you want to ask user.

Return Value

string The input string from standard input.

Exceptions

RuntimeException

string __invoke(string $msg = null, string $default = null)

Proxy to ask method.

Parameters

string $msg Question.
string $default Default value.

Return Value

string The value that use input.

IOInterface getIO()

Method to get property Io

Return Value

IOInterface

AbstractPrompter setIO(IOInterface $io)

Method to set property io

Parameters

IOInterface $io

Return Value

AbstractPrompter Return self to support chaining.

ValidatePrompter setHandler(callable $handler)

Set a callable handler, can be a Closure.

This function should contain a param that is the value which from user input, and must return TRUE or FALSE means validate success or fail.

Parameters

callable $handler The validate callback.

Return Value

ValidatePrompter Return self to support chaining.

callable getHandler()

Get callable handler.

Return Value

callable The validate callback.

ValidatePrompter setAttemptTimes(int $attempt)

Set attempt number.

Parameters

int $attempt Retry times.

Return Value

ValidatePrompter Return self to support chaining.

ValidatePrompter setNoValidMessage(string $noValidMessage)

Set message when validate fail.

Parameters

string $noValidMessage Validate fail message.

Return Value

ValidatePrompter Return self to support chaining.

ValidatePrompter failToClose(boolean $failToClose = null, string $message = '')

If validate fail, whether close application or not.

Parameters

boolean $failToClose TRUE or FALSE, if is NULL, will be getter of $failToClose property.
string $message Message when close.

Return Value

ValidatePrompter Return self to support chaining.