class Argument

Argument.

Constants

IS_INT

Integer flag.

IS_FLOAT

Float flag.

IS_BOOL

Boolean flag.

IS_ARRAY

Array flag.

IS_OPTIONAL

Optional flag.

NAME_REGEX

Regex that matches allowed parameter names.

ALIAS_REGEX

Regex that matches allowed aliases.

Properties

protected string $name Argument name.
protected string|null $alias Argument alias.
protected bool $isPositional Is the argument positional?
protected string $description Argument description.
protected int $options Argument options.
protected mixed $default Default value.

Methods

__construct(string $name, string $description = '', int $options = 0, mixed $default = null)

Constructor.

mixed
getDefaultValue()

Gets the default return value.

string
getValidatedName(string $name)

Returns a validated argument name.

string
getValidatedAlias(string $alias)

Returns a validated alias.

array
parseName(string $name)

Parse the argument name.

int
getValidatedOptions(int $options)

Returns validated options.

string
getName()

Returns the argument name.

string
getNormalizedName()

Returns the normalized argument name.

string|null
getAlias()

Returns the argument alias.

string
getDescription()

Returns the argument description.

bool
isPositional()

Is the argument positional?

bool
isInt()

Is the argument an integer?

bool
isFloat()

Is the argument a float?

bool
isBool()

Is the argument a boolean?

bool
isArray()

Is the argument an array?

bool
isOptional()

Is the argument optional?

Details

at line 127
__construct(string $name, string $description = '', int $options = 0, mixed $default = null)

Constructor.

Parameters

string $name Argument name
string $description Argument description
int $options Argument options
mixed $default Default return value (only used by optional arguments)

at line 154
mixed getDefaultValue()

Gets the default return value.

Return Value

mixed

at line 165
protected string getValidatedName(string $name)

Returns a validated argument name.

Parameters

string $name Argument name

Return Value

string

at line 181
protected string getValidatedAlias(string $alias)

Returns a validated alias.

Parameters

string $alias Alias

Return Value

string

at line 197
protected array parseName(string $name)

Parse the argument name.

Parameters

string $name Argument name

Return Value

array

at line 220
protected int getValidatedOptions(int $options)

Returns validated options.

Parameters

int $options Argument options

Return Value

int

at line 255
string getName()

Returns the argument name.

Return Value

string

at line 265
string getNormalizedName()

Returns the normalized argument name.

Return Value

string

at line 275
string|null getAlias()

Returns the argument alias.

Return Value

string|null

at line 285
string getDescription()

Returns the argument description.

Return Value

string

at line 295
bool isPositional()

Is the argument positional?

Return Value

bool

at line 305
bool isInt()

Is the argument an integer?

Return Value

bool

at line 315
bool isFloat()

Is the argument a float?

Return Value

bool

at line 325
bool isBool()

Is the argument a boolean?

Return Value

bool

at line 335
bool isArray()

Is the argument an array?

Return Value

bool

at line 345
bool isOptional()

Is the argument optional?

Return Value

bool