PHP Class pharext\Cli\Args

Inheritance: implements ArrayAccess
Show file Open project: m6w6/pharext Class Usage Examples

Public Methods

Method Description
__construct ( array | Traversable $spec = null ) Compile the original spec
__get ( $o )
__isset ( $o )
__set ( $o, $v )
__unset ( $o )
compile ( array | Traversable $spec ) : pharext\Cli\Args Compile the original spec
getCompiledSpec ( ) : array Get compiled spec
getSpec ( ) : array Get original spec
offsetExists ( $o )
offsetGet ( $o )
offsetSet ( $o, $v )
offsetUnset ( $o )
parse ( integer $argc, array $argv ) : Generator Parse command line arguments according to the compiled spec.
toArray ( )
validate ( ) : Generator Validate that all required options were given.

Private Methods

Method Description
opt ( string $o ) : string Retreive the canonical name (--long-name) of an option
optAcceptsArg ( string $o ) : boolean Check wether an option accepts any argument
optDefaultArg ( string $o ) : mixed Retreive the default argument of an option
optFlags ( string $o ) : integer Retrieve option's flags
optHalts ( string $o ) : boolean Check whether an option is flagged for halting argument processing
optHelp ( string $o ) : string Retrieve the help message of an option
optIsMulti ( string $o ) : boolean Check whether an option can be used more than once
optLongName ( string $o ) : string Retreive the long name of an option
optRequiresArg ( string $o ) : boolean Check whether an option needs an argument
optShortName ( string $o ) : string Retreive the short name of an option

Method Details

__construct() public method

Compile the original spec
public __construct ( array | Traversable $spec = null )
$spec array | Traversable

__get() public method

public __get ( $o )

__isset() public method

public __isset ( $o )

__set() public method

public __set ( $o, $v )

__unset() public method

public __unset ( $o )

compile() public method

Compile the original spec
public compile ( array | Traversable $spec ) : pharext\Cli\Args
$spec array | Traversable
return pharext\Cli\Args self

getCompiledSpec() public method

Get compiled spec
public getCompiledSpec ( ) : array
return array

getSpec() public method

Get original spec
public getSpec ( ) : array
return array

offsetExists() public method

public offsetExists ( $o )

offsetGet() public method

public offsetGet ( $o )

offsetSet() public method

public offsetSet ( $o, $v )

offsetUnset() public method

public offsetUnset ( $o )

parse() public method

The Generator yields any parsing errors. Parsing will stop when all arguments are processed or the first option flagged Cli\Args::HALT was encountered.
public parse ( integer $argc, array $argv ) : Generator
$argc integer
$argv array
return Generator

toArray() public method

public toArray ( )

validate() public method

The Generator yields any validation errors.
public validate ( ) : Generator
return Generator