class Dispatcher

Command dispatcher.

Traits

Suggestion trait.

Properties

protected Container $container Container.

Methods

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

Returns the string that resembles the provided string the most.

__construct(Container $container)

Constructor.

resolve(string $command)

Resolves the command.

checkForInvalidArguments(CommandInterface $command, array $providedArguments, array $globalOptions)

Checks for invalid arguments or options.

checkForMissingArgumentsOrOptions(array $commandArguments, array $providedArguments, string $exception)

Checks for missing required arguments or options.

checkForMissingArguments(CommandInterface $command, array $providedArguments)

Checks for missing required arguments.

checkForMissingOptions(CommandInterface $command, array $providedArguments)

Checks for missing required options.

checkArgumentsAndOptions(CommandInterface $command, array $providedArguments, array $globalOptions)

Checks arguments and options.

array
convertArgumentsToCamelCase(array $arguments)

Converts arguments to camel case.

mixed
execute(CommandInterface $command, array $arguments)

Executes the command.

int
dispatch(string $command, array $arguments, array $globalOptions)

Dispatches the command.

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 50
__construct(Container $container)

Constructor.

Parameters

Container $container Container

at line 61
protected CommandInterface resolve(string $command)

Resolves the command.

Parameters

string $command Command class

Return Value

CommandInterface

at line 75
protected checkForInvalidArguments(CommandInterface $command, array $providedArguments, array $globalOptions)

Checks for invalid arguments or options.

Parameters

CommandInterface $command Command arguments
array $providedArguments Provided arguments
array $globalOptions Global options

Exceptions

InvalidArgumentException
InvalidOptionException

at line 103
protected checkForMissingArgumentsOrOptions(array $commandArguments, array $providedArguments, string $exception)

Checks for missing required arguments or options.

Parameters

array $commandArguments Command arguments
array $providedArguments Provided arguments
string $exception Exception to throw

Exceptions

ArgumentException

at line 124
protected checkForMissingArguments(CommandInterface $command, array $providedArguments)

Checks for missing required arguments.

Parameters

CommandInterface $command Command instance
array $providedArguments Provided arguments

at line 135
protected checkForMissingOptions(CommandInterface $command, array $providedArguments)

Checks for missing required options.

Parameters

CommandInterface $command Command instance
array $providedArguments Provided arguments

at line 147
protected checkArgumentsAndOptions(CommandInterface $command, array $providedArguments, array $globalOptions)

Checks arguments and options.

Parameters

CommandInterface $command Command instance
array $providedArguments Provided arguments
array $globalOptions Global options

at line 165
protected array convertArgumentsToCamelCase(array $arguments)

Converts arguments to camel case.

Parameters

array $arguments Arguments

Return Value

array

at line 180
protected mixed execute(CommandInterface $command, array $arguments)

Executes the command.

Parameters

CommandInterface $command Command instance
array $arguments Command arguments

Return Value

mixed

at line 193
int dispatch(string $command, array $arguments, array $globalOptions)

Dispatches the command.

Parameters

string $command Command class
array $arguments Command arguments
array $globalOptions Global options

Return Value

int