CallbackPrompter
class CallbackPrompter extends AbstractPrompter (View source)
Callback validate prompter.
It supports custom callback to validate use input and retry if fail.
Methods
Constructor.
Show prompt to ask user.
Proxy to ask method.
Set a callable handler, can be a Closure.
Get callable handler.
Set attempt number.
Set message when validate fail.
If validate fail, whether close application or not.
Details
at line line 77
__construct(string $question = null, callable $handler = null, $default = null, IOInterface $io = null)
Constructor.
at line line 99
string
ask(string $msg = '', string $default = null)
Show prompt to ask user.
in AbstractPrompter at line line 107
string
in(string $question = null)
Get a value from standard input.
in AbstractPrompter at line line 131
string
__invoke(string $msg = null, string $default = null)
Proxy to ask method.
in AbstractPrompter at line line 141
IOInterface
getIO()
Method to get property Io
in AbstractPrompter at line line 153
AbstractPrompter
setIO(IOInterface $io)
Method to set property io
at line line 144
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.
at line line 158
callable
getHandler()
Get callable handler.
at line line 172
ValidatePrompter
setAttemptTimes(int $attempt)
Set attempt number.
at line line 188
ValidatePrompter
setNoValidMessage(string $noValidMessage)
Set message when validate fail.
at line line 205
ValidatePrompter
failToClose(boolean $failToClose = null, string $message = '')
If validate fail, whether close application or not.