PHP Class pho\Console\Console

Datei anzeigen Open project: danielstjules/pho Class Usage Examples

Public Properties

Property Type Description
$formatter
$options

Public Methods

Method Description
__construct ( array $arguments, string $stream ) The constructor stores the arguments to be parsed, and creates instances of both ConsoleFormatter and ConsoleOptionParser. Also, if either a test or spec directory exists, they are set as the default paths to traverse.
getExitStatus ( ) : mixed Returns the error status that should be used to exit after parsing, otherwise it returns null.
getPaths ( ) : array Returns an array of strings corresponding to file and directory paths to be traversed.
getReporterClass ( ) : string Returns the namespaced name of the reporter class requested via the command line arguments, defaulting to DotReporter if not specified.
parseArguments ( ) Parses the arguments originally supplied via the constructor, assigning their values to the option keys in the $options array. If the arguments included the help or version option, the corresponding text is printed.
setExitStatus ( integer $exitStatus ) Sets the error code to be returned.
write ( string $string ) Outputs a single line, replacing all occurrences of the newline character in the string with PHP_EOL for cross-platform support.
writeLn ( string $string ) Outputs a line, followed by a newline, while replacing all occurrences of '\n' in the string with PHP_EOL for cross-platform support.

Private Methods

Method Description
printHelp ( ) Outputs the help text, as required when the --help/-h flag is used. It's done by iterating over $this->availableOptions.
printVersion ( ) Outputs the version information, as defined in the VERSION constant.

Method Details

__construct() public method

The constructor stores the arguments to be parsed, and creates instances of both ConsoleFormatter and ConsoleOptionParser. Also, if either a test or spec directory exists, they are set as the default paths to traverse.
public __construct ( array $arguments, string $stream )
$arguments array An array of argument strings
$stream string The I/O stream to use when writing

getExitStatus() public method

Returns the error status that should be used to exit after parsing, otherwise it returns null.
public getExitStatus ( ) : mixed
return mixed An integer error status, or null

getPaths() public method

Returns an array of strings corresponding to file and directory paths to be traversed.
public getPaths ( ) : array
return array An array of paths

getReporterClass() public method

Returns the namespaced name of the reporter class requested via the command line arguments, defaulting to DotReporter if not specified.
public getReporterClass ( ) : string
return string The namespaced class name of the reporter

parseArguments() public method

Furthermore, if the arguments included a non-valid flag or option, or if any of the listed paths were invalid, error message is printed.
public parseArguments ( )

setExitStatus() public method

Sets the error code to be returned.
public setExitStatus ( integer $exitStatus )
$exitStatus integer An integer return code or exit status

write() public method

Outputs a single line, replacing all occurrences of the newline character in the string with PHP_EOL for cross-platform support.
public write ( string $string )
$string string The string to print

writeLn() public method

Outputs a line, followed by a newline, while replacing all occurrences of '\n' in the string with PHP_EOL for cross-platform support.
public writeLn ( string $string )
$string string The string to print

Property Details

$formatter public_oe property

public $formatter

$options public_oe property

public $options