SubCommandRegistry
in package
Registry for managing sub-commands and their aliases.
Table of Contents
Properties
- $normalizer : callable
- Callable normalizer for command/alias names.
- $subCommandAliases : array<string, string>
- $subCommands : array<string, Command>
Methods
- __construct() : mixed
- all() : array<string, Command>
- Returns all registered sub-commands.
- get() : Command|null
- register() : string
- Register a Command instance and its aliases. Returns the normalized key.
- registerAlias() : void
- unregister() : void
- unregisterAlias() : void
- normalize() : string
Properties
$normalizer
Callable normalizer for command/alias names.
protected
callable
$normalizer
$subCommandAliases
protected
array<string, string>
$subCommandAliases
= []
$subCommands
protected
array<string, Command>
$subCommands
= []
Methods
__construct()
public
__construct(callable $normalizer) : mixed
Parameters
- $normalizer : callable
all()
Returns all registered sub-commands.
public
all() : array<string, Command>
Return values
array<string, Command>get()
public
get(string|null $command[, bool $aliases = true ]) : Command|null
Parameters
- $command : string|null
- $aliases : bool = true
Return values
Command|nullregister()
Register a Command instance and its aliases. Returns the normalized key.
public
register(Command $commandInstance[, array<string|int, mixed> $aliases = [] ]) : string
Parameters
- $commandInstance : Command
- $aliases : array<string|int, mixed> = []
Return values
stringregisterAlias()
public
registerAlias(string $alias, string $command) : void
Parameters
- $alias : string
- $command : string
unregister()
public
unregister(string $command) : void
Parameters
- $command : string
unregisterAlias()
public
unregisterAlias(string $alias) : void
Parameters
- $alias : string
normalize()
protected
normalize(string $name) : string
Parameters
- $name : string