SymfonyQuestionHelper
extends QuestionHelper
in package
Symfony Style Guide compliant question helper.
Tags
Table of Contents
Properties
- $helperSet : mixed
- $inputStream : mixed
- $shell : mixed
- $stty : mixed
Methods
- ask() : mixed
- Asks a question to the user.
- disableStty() : mixed
- Prevents usage of stty.
- formatMemory() : mixed
- formatTime() : mixed
- getHelperSet() : HelperSet|null
- Gets the helper set associated with this helper.
- getInputStream() : resource
- Returns the helper's input stream.
- getName() : string
- Returns the canonical name of this helper.
- removeDecoration() : mixed
- setHelperSet() : mixed
- Sets the helper set associated with this helper.
- setInputStream() : mixed
- Sets the input stream to read from when interacting with the user.
- strlen() : int
- Returns the length of a string, using mb_strwidth if it is available.
- strlenWithoutDecoration() : mixed
- substr() : string
- Returns the subset of a string, using mb_substr if it is available.
- writeError() : mixed
- Outputs an error message.
- writePrompt() : mixed
- Outputs the question prompt.
- autocomplete() : string
- Autocompletes a question.
- doAsk() : bool|mixed|null|string
- Asks the question to the user.
- getHiddenResponse() : string
- Gets a hidden response from user.
- getShell() : string|bool
- Returns a valid unix shell.
- hasSttyAvailable() : bool
- Returns whether Stty is available or not.
- validateAttempts() : mixed
- Validates an attempt.
Properties
$helperSet
protected
mixed
$helperSet
= null
$inputStream
private
mixed
$inputStream
$shell
private
static mixed
$shell
$stty
private
static mixed
$stty
Methods
ask()
Asks a question to the user.
public
ask(InputInterface $input, OutputInterface $output, Question $question) : mixed
Parameters
- $input : InputInterface
-
An InputInterface instance
- $output : OutputInterface
-
An OutputInterface instance
- $question : Question
-
The question to ask
Return values
mixed —The user answer
disableStty()
Prevents usage of stty.
public
static disableStty() : mixed
formatMemory()
public
static formatMemory(mixed $memory) : mixed
Parameters
- $memory : mixed
formatTime()
public
static formatTime(mixed $secs) : mixed
Parameters
- $secs : mixed
getHelperSet()
Gets the helper set associated with this helper.
public
getHelperSet() : HelperSet|null
Return values
HelperSet|nullgetInputStream()
Returns the helper's input stream.
public
getInputStream() : resource
since version 3.2, to be removed in 4.0. Use StreamableInputInterface::getStream() instead.
Return values
resourcegetName()
Returns the canonical name of this helper.
public
getName() : string
Return values
string —The canonical name
removeDecoration()
public
static removeDecoration(OutputFormatterInterface $formatter, mixed $string) : mixed
Parameters
- $formatter : OutputFormatterInterface
- $string : mixed
setHelperSet()
Sets the helper set associated with this helper.
public
setHelperSet([HelperSet $helperSet = null ]) : mixed
Parameters
- $helperSet : HelperSet = null
-
A HelperSet instance
setInputStream()
Sets the input stream to read from when interacting with the user.
public
setInputStream(resource $stream) : mixed
since version 3.2, to be removed in 4.0. Use StreamableInputInterface::setStream() instead.
This is mainly useful for testing purpose.
Parameters
- $stream : resource
-
The input stream
Tags
strlen()
Returns the length of a string, using mb_strwidth if it is available.
public
static strlen(string $string) : int
Parameters
- $string : string
-
The string to check its length
Return values
int —The length of the string
strlenWithoutDecoration()
public
static strlenWithoutDecoration(OutputFormatterInterface $formatter, mixed $string) : mixed
Parameters
- $formatter : OutputFormatterInterface
- $string : mixed
substr()
Returns the subset of a string, using mb_substr if it is available.
public
static substr(string $string, int $from[, int|null $length = null ]) : string
Parameters
- $string : string
-
String to subset
- $from : int
-
Start offset
- $length : int|null = null
-
Length to read
Return values
string —The string subset
writeError()
Outputs an error message.
protected
writeError(OutputInterface $output, Exception $error) : mixed
Parameters
- $output : OutputInterface
- $error : Exception
writePrompt()
Outputs the question prompt.
protected
writePrompt(OutputInterface $output, Question $question) : mixed
Parameters
- $output : OutputInterface
- $question : Question
autocomplete()
Autocompletes a question.
private
autocomplete(OutputInterface $output, Question $question, resource $inputStream) : string
Parameters
- $output : OutputInterface
- $question : Question
- $inputStream : resource
Return values
stringdoAsk()
Asks the question to the user.
private
doAsk(OutputInterface $output, Question $question) : bool|mixed|null|string
Parameters
- $output : OutputInterface
- $question : Question
Tags
Return values
bool|mixed|null|stringgetHiddenResponse()
Gets a hidden response from user.
private
getHiddenResponse(OutputInterface $output, resource $inputStream) : string
Parameters
- $output : OutputInterface
-
An Output instance
- $inputStream : resource
-
The handler resource
Tags
Return values
string —The answer
getShell()
Returns a valid unix shell.
private
getShell() : string|bool
Return values
string|bool —The valid shell name, false in case no valid shell is found
hasSttyAvailable()
Returns whether Stty is available or not.
private
hasSttyAvailable() : bool
Return values
boolvalidateAttempts()
Validates an attempt.
private
validateAttempts(callable $interviewer, OutputInterface $output, Question $question) : mixed
Parameters
- $interviewer : callable
-
A callable that will ask for a question and return the result
- $output : OutputInterface
-
An Output instance
- $question : Question
-
A Question instance
Tags
Return values
mixed —The validated response