Documentation

SymfonyQuestionHelper extends QuestionHelper
in package

Symfony Style Guide compliant question helper.

Tags
author

Kevin Bond kevinbond@gmail.com

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

Methods

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|null

getInputStream()

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
resource

getName()

Returns the canonical name of this helper.

public getName() : string
Return values
string

The canonical name

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
throws
InvalidArgumentException

In case the stream is not a resource

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

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

getHiddenResponse()

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
throws
RuntimeException

In case the fallback is deactivated and the response cannot be hidden

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
bool

validateAttempts()

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
throws
Exception

In case the max number of attempts has been reached and no valid response has been given

Return values
mixed

The validated response


        
On this page

Search results