PHP Class Symfony\Component\Console\Helper\DialogHelper

Author: Fabien Potencier ([email protected])
Inheritance: extends Helper
Mostrar archivo Open project: pmjones/php-framework-benchmarks Class Usage Examples

Public Methods

Method Description
ask ( Symfony\Component\Console\Output\OutputInterface $output, string | array $question, string $default = null ) : string Asks a question to the user.
askAndValidate ( Symfony\Component\Console\Output\OutputInterface $output, string | array $question, callback $validator, integer $attempts = false, string $default = null ) : mixed Asks for a value and validates the response.
askConfirmation ( Symfony\Component\Console\Output\OutputInterface $output, string | array $question, boolean $default = true ) : boolean Asks a confirmation to the user.
getName ( ) Returns the helper's canonical name
setInputStream ( resource $stream ) Sets the input stream to read from when interacting with the user.

Method Details

ask() public method

Asks a question to the user.
public ask ( Symfony\Component\Console\Output\OutputInterface $output, string | array $question, string $default = null ) : string
$output Symfony\Component\Console\Output\OutputInterface
$question string | array The question to ask
$default string The default answer if none is given by the user
return string The user answer

askAndValidate() public method

The validator receives the data to validate. It must return the validated data when the data is valid and throw an exception otherwise.
public askAndValidate ( Symfony\Component\Console\Output\OutputInterface $output, string | array $question, callback $validator, integer $attempts = false, string $default = null ) : mixed
$output Symfony\Component\Console\Output\OutputInterface
$question string | array
$validator callback A PHP callback
$attempts integer Max number of times to ask before giving up (false by default, which means infinite)
$default string The default answer if none is given by the user
return mixed

askConfirmation() public method

The question will be asked until the user answer by nothing, yes, or no.
public askConfirmation ( Symfony\Component\Console\Output\OutputInterface $output, string | array $question, boolean $default = true ) : boolean
$output Symfony\Component\Console\Output\OutputInterface
$question string | array The question to ask
$default boolean The default answer if the user enters nothing
return boolean true if the user has confirmed, false otherwise

getName() public method

Returns the helper's canonical name
public getName ( )

setInputStream() public method

This is mainly useful for testing purpose.
public setInputStream ( resource $stream )
$stream resource The input stream