class Reactor

Reactor.

Traits

Suggestion trait.

Properties

protected Input $input Input.
protected Output $output Output.
protected Container $container Container.
protected Dispatcher $dispatcher Dispatcher.
protected array $commands Commands.
$logo Logo.

Methods

string|null
suggest(string $string, array $alternatives)

Returns the string that resembles the provided string the most.

__construct(Input $input, Output $output, Container|null $container = null, Dispatcher|null $dispatcher = null)

Constructor.

getInput()

Returns the input.

getOutput()

Returns the output.

registerCommand(string $command, string $class)

Registers a command.

setLogo(string $logo)

Sets the reactor logo.

setup()

Setup the reactor.

drawTable(string $heading, array $headers, array $rows)

Draws information table.

drawArgumentTable(string $heading, array $arguments)

Draws an argument table.

displayReactorInfo()

Displays basic reactor information.

instantiateCommandWithoutConstructor(string $class)

Instantiates command without calling the constructor.

array
getCommands()

Returns an array of command information.

listCommands()

Lists available commands if there are any.

int
displayReactorInfoAndCommandList()

Displays reactor info and lists all available commands.

bool
commandExists(string $command)

Returns TRUE if the command exists and FALSE if not.

int
unknownCommand(string $command)

Displays error message for unknown commands.

int
displayCommandHelp(string $command)

Displays information about the chosen command.

int
registerCommandArgumentsAndDispatch(string $command)

Registers the command arguments and dispatches the command.

int
run()

Run the reactor.

Details

in SuggestionTrait at line 27
protected string|null suggest(string $string, array $alternatives)

Returns the string that resembles the provided string the most.

NULL is returned if no string with a similarity of 66% or more is found.

Parameters

string $string String
array $alternatives Alternatives

Return Value

string|null

at line 85
__construct(Input $input, Output $output, Container|null $container = null, Dispatcher|null $dispatcher = null)

Constructor.

Parameters

Input $input Input
Output $output Output
Container|null $container Container
Dispatcher|null $dispatcher Command dispatcher

at line 101
Input getInput()

Returns the input.

Return Value

Input

at line 111
Output getOutput()

Returns the output.

Return Value

Output

at line 122
registerCommand(string $command, string $class)

Registers a command.

Parameters

string $command Command
string $class Command class

Sets the reactor logo.

Parameters

string $logo ASCII logo

at line 140
protected setup()

Setup the reactor.

at line 166
protected drawTable(string $heading, array $headers, array $rows)

Draws information table.

Parameters

string $heading Table heading
array $headers Table headers
array $rows Table rows

at line 190
protected drawArgumentTable(string $heading, array $arguments)

Draws an argument table.

Parameters

string $heading Table heading
array $arguments Arguments

at line 210
protected displayReactorInfo()

Displays basic reactor information.

at line 242
protected CommandInterface instantiateCommandWithoutConstructor(string $class)

Instantiates command without calling the constructor.

Parameters

string $class Class name

Return Value

CommandInterface

at line 252
protected array getCommands()

Returns an array of command information.

Return Value

array

at line 271
protected listCommands()

Lists available commands if there are any.

at line 283
protected int displayReactorInfoAndCommandList()

Displays reactor info and lists all available commands.

Return Value

int

at line 298
protected bool commandExists(string $command)

Returns TRUE if the command exists and FALSE if not.

Parameters

string $command Command

Return Value

bool

at line 309
protected int unknownCommand(string $command)

Displays error message for unknown commands.

Parameters

string $command Command

Return Value

int

at line 331
protected int displayCommandHelp(string $command)

Displays information about the chosen command.

Parameters

string $command Command

Return Value

int

at line 360
protected int registerCommandArgumentsAndDispatch(string $command)

Registers the command arguments and dispatches the command.

Parameters

string $command

Return Value

int

at line 374
int run()

Run the reactor.

Return Value

int