IOInterface
in
The Input/Output helper interface.
Tags
Table of Contents
- DEBUG = 16
- NORMAL = 2
- QUIET = 1
- VERBOSE = 4
- VERY_VERBOSE = 8
- ask() : string
- Asks a question to the user.
- askAndHideAnswer() : string
- Asks a question to the user and hide the answer.
- askAndValidate() : mixed
- Asks for a value and validates the response.
- askConfirmation() : bool
- Asks a confirmation to the user.
- getAuthentication() : array<string|int, mixed>
- Get the username and password of repository.
- getAuthentications() : array<string|int, mixed>
- Get all authentication information entered.
- hasAuthentication() : bool
- Verify if the repository has a authentication information.
- isDebug() : bool
- Is the output in debug verbosity?
- isDecorated() : bool
- Is this output decorated?
- isInteractive() : bool
- Is this input means interactive?
- isVerbose() : bool
- Is this output verbose?
- isVeryVerbose() : bool
- Is the output very verbose?
- loadConfiguration() : mixed
- Loads authentications from a config instance
- overwrite() : mixed
- Overwrites a previous message to the output.
- overwriteError() : mixed
- Overwrites a previous message to the error output.
- select() : int|string|array<string|int, mixed>
- Asks the user to select a value.
- setAuthentication() : mixed
- Set the authentication information for the repository.
- write() : mixed
- Writes a message to the output.
- writeError() : mixed
- Writes a message to the error output.
Constants
DEBUG
public
mixed
DEBUG
= 16
NORMAL
public
mixed
NORMAL
= 2
QUIET
public
mixed
QUIET
= 1
VERBOSE
public
mixed
VERBOSE
= 4
VERY_VERBOSE
public
mixed
VERY_VERBOSE
= 8
Methods
ask()
Asks a question to the user.
public
ask(string $question[, string $default = null ]) : string
Parameters
- $question : string
-
The question to ask
- $default : string = null
-
The default answer if none is given by the user
Tags
Return values
string —The user answer
askAndHideAnswer()
Asks a question to the user and hide the answer.
public
askAndHideAnswer(string $question) : string
Parameters
- $question : string
-
The question to ask
Return values
string —The answer
askAndValidate()
Asks for a value and validates the response.
public
askAndValidate(string $question, callable $validator[, null|int $attempts = null ][, mixed $default = null ]) : mixed
The validator receives the data to validate. It must return the validated data when the data is valid and throw an exception otherwise.
Parameters
- $question : string
-
The question to ask
- $validator : callable
-
A PHP callback
- $attempts : null|int = null
-
Max number of times to ask before giving up (default of null means infinite)
- $default : mixed = null
-
The default answer if none is given by the user
Tags
Return values
mixed —askConfirmation()
Asks a confirmation to the user.
public
askConfirmation(string $question[, bool $default = true ]) : bool
The question will be asked until the user answers by nothing, yes, or no.
Parameters
- $question : string
-
The question to ask
- $default : bool = true
-
The default answer if the user enters nothing
Return values
bool —true if the user has confirmed, false otherwise
getAuthentication()
Get the username and password of repository.
public
getAuthentication(string $repositoryName) : array<string|int, mixed>
Parameters
- $repositoryName : string
-
The unique name of repository
Return values
array<string|int, mixed> —The 'username' and 'password'
getAuthentications()
Get all authentication information entered.
public
getAuthentications() : array<string|int, mixed>
Return values
array<string|int, mixed> —The map of authentication data
hasAuthentication()
Verify if the repository has a authentication information.
public
hasAuthentication(string $repositoryName) : bool
Parameters
- $repositoryName : string
-
The unique name of repository
Return values
bool —isDebug()
Is the output in debug verbosity?
public
isDebug() : bool
Return values
bool —isDecorated()
Is this output decorated?
public
isDecorated() : bool
Return values
bool —isInteractive()
Is this input means interactive?
public
isInteractive() : bool
Return values
bool —isVerbose()
Is this output verbose?
public
isVerbose() : bool
Return values
bool —isVeryVerbose()
Is the output very verbose?
public
isVeryVerbose() : bool
Return values
bool —loadConfiguration()
Loads authentications from a config instance
public
loadConfiguration(Config $config) : mixed
Parameters
- $config : Config
Return values
mixed —overwrite()
Overwrites a previous message to the output.
public
overwrite(string|array<string|int, mixed> $messages[, bool $newline = true ][, int $size = null ][, int $verbosity = self::NORMAL ]) : mixed
Parameters
- $messages : string|array<string|int, mixed>
-
The message as an array of lines or a single string
- $newline : bool = true
-
Whether to add a newline or not
- $size : int = null
-
The size of line
- $verbosity : int = self::NORMAL
-
Verbosity level from the VERBOSITY_* constants
Return values
mixed —overwriteError()
Overwrites a previous message to the error output.
public
overwriteError(string|array<string|int, mixed> $messages[, bool $newline = true ][, int $size = null ][, int $verbosity = self::NORMAL ]) : mixed
Parameters
- $messages : string|array<string|int, mixed>
-
The message as an array of lines or a single string
- $newline : bool = true
-
Whether to add a newline or not
- $size : int = null
-
The size of line
- $verbosity : int = self::NORMAL
-
Verbosity level from the VERBOSITY_* constants
Return values
mixed —select()
Asks the user to select a value.
public
select(string $question, array<string|int, mixed> $choices, bool|string $default[, bool|int $attempts = false ][, string $errorMessage = 'Value "%s" is invalid' ][, bool $multiselect = false ]) : int|string|array<string|int, mixed>
Parameters
- $question : string
-
The question to ask
- $choices : array<string|int, mixed>
-
List of choices to pick from
- $default : bool|string
-
The default answer if the user enters nothing
- $attempts : bool|int = false
-
Max number of times to ask before giving up (false by default, which means infinite)
- $errorMessage : string = 'Value "%s" is invalid'
-
Message which will be shown if invalid value from choice list would be picked
- $multiselect : bool = false
-
Select more than one value separated by comma
Tags
Return values
int|string|array<string|int, mixed> —The selected value or values (the key of the choices array)
setAuthentication()
Set the authentication information for the repository.
public
setAuthentication(string $repositoryName, string $username[, string $password = null ]) : mixed
Parameters
- $repositoryName : string
-
The unique name of repository
- $username : string
-
The username
- $password : string = null
-
The password
Return values
mixed —write()
Writes a message to the output.
public
write(string|array<string|int, mixed> $messages[, bool $newline = true ][, int $verbosity = self::NORMAL ]) : mixed
Parameters
- $messages : string|array<string|int, mixed>
-
The message as an array of lines or a single string
- $newline : bool = true
-
Whether to add a newline or not
- $verbosity : int = self::NORMAL
-
Verbosity level from the VERBOSITY_* constants
Return values
mixed —writeError()
Writes a message to the error output.
public
writeError(string|array<string|int, mixed> $messages[, bool $newline = true ][, int $verbosity = self::NORMAL ]) : mixed
Parameters
- $messages : string|array<string|int, mixed>
-
The message as an array of lines or a single string
- $newline : bool = true
-
Whether to add a newline or not
- $verbosity : int = self::NORMAL
-
Verbosity level from the VERBOSITY_* constants