PHP Класс SimpleArguments, simpletest

Показать файл Открыть проект Примеры использования класса

Открытые методы

Метод Описание
__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.

Приватные методы

Метод Описание
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.

Описание методов

__construct() публичный Метод

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() публичный Метод

The arguments are available as individual member variables on the object.
public __get ( string $key ) : string/array/boolean
$key string Argument name.
Результат string/array/boolean

all() публичный Метод

The entire argument set as a hash.
public all ( ) : hash
Результат hash Each argument and it's value(s).

assign() публичный Метод

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() публичный Метод

It's a flag if it starts with "-" or "--".
public isFlag ( string $argument ) : boolean
$argument string Value to be tested.
Результат boolean True if it's a flag.

valueIsNext() публичный Метод

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.