UnknownCommandException
extends Exception
in package
UnknownCommandException represents an exception caused by incorrect usage of a console command.
Tags
Table of Contents
Properties
- $command : string
- $application : Application
Methods
- __construct() : mixed
- Construct the exception.
- getName() : string
- getSuggestedAlternatives() : array<string|int, mixed>
- Suggest alternative commands for [[$command]] based on string similarity.
- filterBySimilarity() : array<string|int, mixed>
- Find suggest alternative commands based on string similarity.
Properties
$command
public
string
$command
the name of the command that could not be recognized.
$application
protected
Application
$application
Methods
__construct()
Construct the exception.
public
__construct(string $route, Application $application[, int $code = 0 ][, Throwable|null $previous = null ]) : mixed
Parameters
- $route : string
-
the route of the command that could not be found.
- $application : Application
-
the console application instance involved.
- $code : int = 0
-
the Exception code.
- $previous : Throwable|null = null
-
the previous exception used for the exception chaining.
getName()
public
getName() : string
Return values
string —the user-friendly name of this exception
getSuggestedAlternatives()
Suggest alternative commands for [[$command]] based on string similarity.
public
getSuggestedAlternatives() : array<string|int, mixed>
Alternatives are searched using the following steps:
- suggest alternatives that begin with
$command
- find typos by calculating the Levenshtein distance between the unknown command and all available commands. The Levenshtein distance is defined as the minimal number of characters you have to replace, insert or delete to transform str1 into str2.
Tags
Return values
array<string|int, mixed> —a list of suggested alternatives sorted by similarity.
filterBySimilarity()
Find suggest alternative commands based on string similarity.
private
filterBySimilarity(array<string|int, mixed> $actions, string $command) : array<string|int, mixed>
Alternatives are searched using the following steps:
- suggest alternatives that begin with
$command
- find typos by calculating the Levenshtein distance between the unknown command and all available commands. The Levenshtein distance is defined as the minimal number of characters you have to replace, insert or delete to transform str1 into str2.
Parameters
- $actions : array<string|int, mixed>
-
available command names.
- $command : string
-
the command to compare to.
Tags
Return values
array<string|int, mixed> —a list of suggested alternatives sorted by similarity.