MockInputOutput
extends InputOutput
in package
FinalYes
Input and Output for CLI.
Table of Contents
Properties
- $inputs : array<int, string>
- String to be entered by the user.
- $outputs : array<int, string>
- Output lines.
- $readlineSupport : bool
- Is the readline library on the system?
Methods
- __construct() : mixed
- fwrite() : void
- While the library is intended for use on CLI commands, commands can be called from controllers and elsewhere so we need a way to allow them to still work.
- getOutput() : string
- Gets the item from the output array.
- getOutputs() : array<string|int, mixed>
- Returns the outputs array.
- input() : string
- Get input from the shell, using readline or the standard STDIN
- setInputs() : void
- Sets user inputs.
- addStreamFilters() : void
- removeStreamFilters() : void
Properties
$inputs
String to be entered by the user.
private
array<int, string>
$inputs
= []
$outputs
Output lines.
private
array<int, string>
$outputs
= []
Tags
$readlineSupport read-only
Is the readline library on the system?
private
bool
$readlineSupport
Methods
__construct()
public
__construct() : mixed
fwrite()
While the library is intended for use on CLI commands, commands can be called from controllers and elsewhere so we need a way to allow them to still work.
public
fwrite(mixed $handle, string $string) : void
For now, just echo the content, but look into a better solution down the road.
Parameters
- $handle : mixed
- $string : string
getOutput()
Gets the item from the output array.
public
getOutput([int|null $index = null ]) : string
Parameters
- $index : int|null = null
-
The output array index. If null, returns all output string. If negative int, returns the last $index-th item.
Return values
stringgetOutputs()
Returns the outputs array.
public
getOutputs() : array<string|int, mixed>
Return values
array<string|int, mixed>input()
Get input from the shell, using readline or the standard STDIN
public
input([string|null $prefix = null ]) : string
Named options must be in the following formats: php index.php user -v --v -name=John --name=John
Parameters
- $prefix : string|null = null
-
You may specify a string with which to prompt the user.
Return values
stringsetInputs()
Sets user inputs.
public
setInputs(array<int, string> $inputs) : void
Parameters
- $inputs : array<int, string>
Tags
addStreamFilters()
private
addStreamFilters() : void
removeStreamFilters()
private
removeStreamFilters() : void