ConsoleInputArgument
in package
An object to represent a single argument used in the command line.
ConsoleOptionParser creates these when you use addArgument()
Tags
Table of Contents
Properties
- $_choices : array<string|int, string>
- An array of valid choices for this argument.
- $_help : string
- Help string
- $_name : string
- Name of the argument.
- $_required : bool
- Is this option required?
Methods
- __construct() : mixed
- Make a new Input Argument
- help() : string
- Generate the help for this argument.
- isEqualTo() : bool
- Checks if this argument is equal to another argument.
- isRequired() : bool
- Check if this argument is a required argument
- name() : string
- Get the value of the name attribute.
- usage() : string
- Get the usage value for this argument
- validChoice() : true
- Check that $value is a valid choice for this argument.
- xml() : SimpleXMLElement
- Append this arguments XML representation to the passed in SimpleXml object.
Properties
$_choices
An array of valid choices for this argument.
protected
array<string|int, string>
$_choices
$_help
Help string
protected
string
$_help
$_name
Name of the argument.
protected
string
$_name
$_required
Is this option required?
protected
bool
$_required
Methods
__construct()
Make a new Input Argument
public
__construct(array<string, mixed>|string $name[, string $help = '' ][, bool $required = false ][, array<string|int, string> $choices = [] ]) : mixed
Parameters
- $name : array<string, mixed>|string
-
The long name of the option, or an array with all the properties.
- $help : string = ''
-
The help text for this option
- $required : bool = false
-
Whether this argument is required. Missing required args will trigger exceptions
- $choices : array<string|int, string> = []
-
Valid choices for this option.
help()
Generate the help for this argument.
public
help([int $width = 0 ]) : string
Parameters
- $width : int = 0
-
The width to make the name of the option.
Return values
stringisEqualTo()
Checks if this argument is equal to another argument.
public
isEqualTo(ConsoleInputArgument $argument) : bool
Parameters
- $argument : ConsoleInputArgument
-
ConsoleInputArgument to compare to.
Return values
boolisRequired()
Check if this argument is a required argument
public
isRequired() : bool
Return values
boolname()
Get the value of the name attribute.
public
name() : string
Return values
string —Value of this->_name.
usage()
Get the usage value for this argument
public
usage() : string
Return values
stringvalidChoice()
Check that $value is a valid choice for this argument.
public
validChoice(string $value) : true
Parameters
- $value : string
-
The choice to validate.
Tags
Return values
truexml()
Append this arguments XML representation to the passed in SimpleXml object.
public
xml(SimpleXMLElement $parent) : SimpleXMLElement
Parameters
- $parent : SimpleXMLElement
-
The parent element.
Return values
SimpleXMLElement —The parent with this argument appended.