ArgvParser
class ArgvParser
Argument parser.
Traits
Constants
INT_REGEX |
Regex that matches integers. |
FLOAT_REGEX |
Regex that matches floats. |
Properties
protected array | $argv | Argv. | |
protected array | $arguments | Arguments. | |
protected array | $map | Map. | |
protected array | $positionals | Positional arguments. | |
protected array | $parsed | Parsed arguments. | |
protected bool | $ignoreUnknownArguments | Should unknown arguments be ignored? |
Methods
Returns the string that resembles the provided string the most.
Constructor.
Returns the registered arguments.
Tries to find a suggestion for the invalid argument name.
Returns an argument based on its name.
Clears the parsed argument cache.
Add arguments.
Stores option values.
Parses an option.
Parses an alias.
Parses a positional argument.
Parses the arguments.
Returns the value of a parsed argument.
Details
in SuggestionTrait at line 25
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.
at line 96
__construct(array $argv, array $arguments = [])
Constructor.
at line 108
array
getArguments()
Returns the registered arguments.
at line 119
protected string|null
findArgumentSuggestion(string $name)
Tries to find a suggestion for the invalid argument name.
at line 130
protected Argument|null
getArgument(string $name)
Returns an argument based on its name.
at line 150
ArgvParser
clearCache()
Clears the parsed argument cache.
at line 162
addArgument(Argument $argument)
Add argument.
at line 210
addArguments(array $arguments)
Add arguments.
at line 226
protected bool|float|int|string
castValue(Argument $argument, string|null $token, bool|string $value)
Casts the value to the desired type.
at line 257
protected
storeValue(Argument $argument, string|null $token, bool|string|null $value)
Store the value.
at line 284
protected
storeOptionValue(Argument $argument, string $token, string|null $value, array $tokens)
Stores option values.
at line 312
protected
parseOption(string $token, array $tokens)
Parses an option.
at line 335
protected
parseAlias(string $token, array $tokens)
Parses an alias.
at line 372
protected
parsePositional(string $token, array $positionals, array $tokens, bool $parseOptions)
Parses a positional argument.
at line 405
array
parse(bool $ignoreUnknownArguments = false)
Parses the arguments.
at line 467
mixed
getArgumentValue(string $argument, mixed $default = null, bool $ignoreUnknownArguments = false)
Returns the value of a parsed argument.