PHP Class SimpleArguments, simpletest

Afficher le fichier Open project: simpletest/simpletest Class Usage Examples

Méthodes publiques

Méthode Description
__construct ( array $arguments ) Parses the command line arguments.
__get ( string $key ) : string/array/boolean The arguments are available as individual member variables on the object.
all ( ) : hash The entire argument set as a hash.
assign ( string $key, $value ) Sets the value in the argments object. If multiple values are added under the same key, the key will give an array value in the order they were added.
isFlag ( string $argument ) : boolean It's a flag if it starts with "-" or "--".
valueIsNext ( array $arguments ) Test to see if the next available argument is a valid value.

Private Methods

Méthode Description
nextNonFlagElseTrue ( array &$arguments ) : string/boolean Attempts to use the next argument as a value.
parseArgument ( array &$arguments ) : array Extracts the next key and value from the argument list.

Method Details

__construct() public méthode

The usual formats are supported: -f value -f=value --flag=value --flag value -f (true) --flag (true)
public __construct ( array $arguments )
$arguments array Normally the PHP $argv.

__get() public méthode

The arguments are available as individual member variables on the object.
public __get ( string $key ) : string/array/boolean
$key string Argument name.
Résultat string/array/boolean

all() public méthode

The entire argument set as a hash.
public all ( ) : hash
Résultat hash Each argument and it's value(s).

assign() public méthode

Sets the value in the argments object. If multiple values are added under the same key, the key will give an array value in the order they were added.
public assign ( string $key, $value )
$key string The variable to assign to.

isFlag() public méthode

It's a flag if it starts with "-" or "--".
public isFlag ( string $argument ) : boolean
$argument string Value to be tested.
Résultat boolean True if it's a flag.

valueIsNext() public méthode

If it starts with "-" or "--" it's a flag and doesn't count.
public valueIsNext ( array $arguments )
$arguments array Remaining arguments to be parsed. Not affected by this call. boolean True if valid value.