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.
protected array $options Options.
$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.

registerCommand(string $command, string $class)

Registers a command.

registerGlobalOption(string $name, string $description, Closure $handler, string $group = 'default')

Register a global reactor option.

setLogo(string $logo)

Sets the reactor logo.

handleGlobalOptions(string $group = 'default')

Handles global reactor options.

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

Draws information table.

array
getOptions()

Returns an array of option information.

listOptions()

Displays global reactor options of there are any.

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.

array
convertArgumentsAndOptionsArrayToRows(array $input)

Converst the argument and options arrays to table rows.

int
displayCommandHelp(string $command)

Displays information about the chosen command.

bool
commandExists(string $command)

Returns true if the command exists and false if not.

int
unknownCommand(string $command)

Displays error message for unknown commands.

array
getGlobalOptionNames()

Returns the names of the global options.

int
dispatch(string $command)

Dispatches a 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 95
__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 112
registerCommand(string $command, string $class)

Registers a command.

Parameters

string $command Command
string $class Command class

at line 125
registerGlobalOption(string $name, string $description, Closure $handler, string $group = 'default')

Register a global reactor option.

Parameters

string $name Option name
string $description Option description
Closure $handler Option handler
string $group Option group

Sets the reactor logo.

Parameters

string $logo ASCII logo

at line 145
handleGlobalOptions(string $group = 'default')

Handles global reactor options.

Parameters

string $group Option group

at line 170
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 193
protected array getOptions()

Returns an array of option information.

Return Value

array

at line 213
protected listOptions()

Displays global reactor options of there are any.

at line 223
protected displayReactorInfo()

Displays basic reactor information.

at line 251
protected CommandInterface instantiateCommandWithoutConstructor(string $class)

Instantiates command without calling the constructor.

Parameters

string $class Class name

Return Value

CommandInterface

at line 261
protected array getCommands()

Returns an array of command information.

Return Value

array

at line 280
protected listCommands()

Lists available commands if there are any.

at line 292
protected int displayReactorInfoAndCommandList()

Displays reactor info and lists all available commands.

Return Value

int

at line 307
protected array convertArgumentsAndOptionsArrayToRows(array $input)

Converst the argument and options arrays to table rows.

Parameters

array $input Argument or option array

Return Value

array

at line 325
protected int displayCommandHelp(string $command)

Displays information about the chosen command.

Parameters

string $command Command

Return Value

int

at line 362
protected bool commandExists(string $command)

Returns true if the command exists and false if not.

Parameters

string $command Command

Return Value

bool

at line 373
protected int unknownCommand(string $command)

Displays error message for unknown commands.

Parameters

string $command Command

Return Value

int

at line 394
protected array getGlobalOptionNames()

Returns the names of the global options.

Return Value

array

at line 412
protected int dispatch(string $command)

Dispatches a command.

Parameters

string $command Command

Return Value

int

at line 435
int run()

Run the reactor.

Return Value

int