PHP Class SimpleArguments, simpletest

ファイルを表示 Open project: simpletest/simpletest Class Usage Examples

Public Methods

Method 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

Method 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 method

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 method

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

all() public method

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

assign() public method

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 method

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

valueIsNext() public method

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.