Composer API
Interface

Composer\IO\IOInterface

interface IOInterface

The Input/Output helper interface.

Constants

QUIET

NORMAL

VERBOSE

VERY_VERBOSE

DEBUG

Methods

bool isInteractive()

Is this input means interactive?

bool isVerbose()

Is this output verbose?

bool isVeryVerbose()

Is the output very verbose?

bool isDebug()

Is the output in debug verbosity?

bool isDecorated()

Is this output decorated?

write(string|array $messages, bool $newline = true, int $verbosity = self::NORMAL)

Writes a message to the output.

writeError(string|array $messages, bool $newline = true, int $verbosity = self::NORMAL)

Writes a message to the error output.

overwrite(string|array $messages, bool $newline = true, int $size = null, int $verbosity = self::NORMAL)

Overwrites a previous message to the output.

overwriteError(string|array $messages, bool $newline = true, int $size = null, int $verbosity = self::NORMAL)

Overwrites a previous message to the error output.

string ask(string|array $question, string $default = null)

Asks a question to the user.

bool askConfirmation(string|array $question, bool $default = true)

Asks a confirmation to the user.

mixed askAndValidate(string|array $question, callable $validator, null|int $attempts = null, mixed $default = null)

Asks for a value and validates the response.

string askAndHideAnswer(string $question)

Asks a question to the user and hide the answer.

int|string|array select(string|array $question, array $choices, bool|string $default, bool|int $attempts = false, string $errorMessage = 'Value "%s" is invalid', bool $multiselect = false)

Asks the user to select a value.

array getAuthentications()

Get all authentication information entered.

bool hasAuthentication(string $repositoryName)

Verify if the repository has a authentication information.

array getAuthentication(string $repositoryName)

Get the username and password of repository.

setAuthentication(string $repositoryName, string $username, string $password = null)

Set the authentication information for the repository.

loadConfiguration(Config $config)

Loads authentications from a config instance

Details

at line 35
public bool isInteractive()

Is this input means interactive?

Return Value

bool

at line 42
public bool isVerbose()

Is this output verbose?

Return Value

bool

at line 49
public bool isVeryVerbose()

Is the output very verbose?

Return Value

bool

at line 56
public bool isDebug()

Is the output in debug verbosity?

Return Value

bool

at line 63
public bool isDecorated()

Is this output decorated?

Return Value

bool

at line 72
public write(string|array $messages, bool $newline = true, int $verbosity = self::NORMAL)

Writes a message to the output.

Parameters

string|array $messages The message as an array of lines or a single string
bool $newline Whether to add a newline or not
int $verbosity Verbosity level from the VERBOSITY_* constants

at line 81
public writeError(string|array $messages, bool $newline = true, int $verbosity = self::NORMAL)

Writes a message to the error output.

Parameters

string|array $messages The message as an array of lines or a single string
bool $newline Whether to add a newline or not
int $verbosity Verbosity level from the VERBOSITY_* constants

at line 91
public overwrite(string|array $messages, bool $newline = true, int $size = null, int $verbosity = self::NORMAL)

Overwrites a previous message to the output.

Parameters

string|array $messages The message as an array of lines or a single string
bool $newline Whether to add a newline or not
int $size The size of line
int $verbosity Verbosity level from the VERBOSITY_* constants

at line 101
public overwriteError(string|array $messages, bool $newline = true, int $size = null, int $verbosity = self::NORMAL)

Overwrites a previous message to the error output.

Parameters

string|array $messages The message as an array of lines or a single string
bool $newline Whether to add a newline or not
int $size The size of line
int $verbosity Verbosity level from the VERBOSITY_* constants

at line 112
public string ask(string|array $question, string $default = null)

Asks a question to the user.

Parameters

string|array $question The question to ask
string $default The default answer if none is given by the user

Return Value

string The user answer

Exceptions

RuntimeException If there is no data to read in the input stream

at line 124
public bool askConfirmation(string|array $question, bool $default = true)

Asks a confirmation to the user.

The question will be asked until the user answers by nothing, yes, or no.

Parameters

string|array $question The question to ask
bool $default The default answer if the user enters nothing

Return Value

bool true if the user has confirmed, false otherwise

at line 141
public mixed askAndValidate(string|array $question, callable $validator, null|int $attempts = null, mixed $default = null)

Asks for a value and validates the response.

The validator receives the data to validate. It must return the validated data when the data is valid and throw an exception otherwise.

Parameters

string|array $question The question to ask
callable $validator A PHP callback
null|int $attempts Max number of times to ask before giving up (default of null means infinite)
mixed $default The default answer if none is given by the user

Return Value

mixed

Exceptions

Exception When any of the validators return an error

at line 150
public string askAndHideAnswer(string $question)

Asks a question to the user and hide the answer.

Parameters

string $question The question to ask

Return Value

string The answer

at line 165
public int|string|array select(string|array $question, array $choices, bool|string $default, bool|int $attempts = false, string $errorMessage = 'Value "%s" is invalid', bool $multiselect = false)

Asks the user to select a value.

Parameters

string|array $question The question to ask
array $choices List of choices to pick from
bool|string $default The default answer if the user enters nothing
bool|int $attempts Max number of times to ask before giving up (false by default, which means infinite)
string $errorMessage Message which will be shown if invalid value from choice list would be picked
bool $multiselect Select more than one value separated by comma

Return Value

int|string|array The selected value or values (the key of the choices array)

Exceptions

InvalidArgumentException

at line 172
public array getAuthentications()

Get all authentication information entered.

Return Value

array The map of authentication data

at line 181
public bool hasAuthentication(string $repositoryName)

Verify if the repository has a authentication information.

Parameters

string $repositoryName The unique name of repository

Return Value

bool

at line 190
public array getAuthentication(string $repositoryName)

Get the username and password of repository.

Parameters

string $repositoryName The unique name of repository

Return Value

array The 'username' and 'password'

at line 199
public setAuthentication(string $repositoryName, string $username, string $password = null)

Set the authentication information for the repository.

Parameters

string $repositoryName The unique name of repository
string $username The username
string $password The password

at line 206
public loadConfiguration(Config $config)

Loads authentications from a config instance

Parameters

Config $config