ConsoleTools: ezcConsoleStatusbar
[ ]
[ ]
[ ]
[ ]
[ ]
Class: ezcConsoleStatusbar
|
Creating and maintaining statusbars to be printed to the console. [
source]
1. // Construction
2. $status = new ezcConsoleStatusbar( new ezcConsoleOutput() );
3.
4. // Set option
5. $status->options->successChar = '*';
6.
7. // Run statusbar
8. foreach ( $files as $file )
9. {
10. $res = $file->upload();
11. // Add status if form of bool true/false to statusbar.
12. $status->add( $res ); // $res is true or false
13. }
14.
15. // Retreive and display final statusbar results
16. $msg = $status->getSuccess() . ' succeeded, ' . $status->getFailure() . ' failed.';
17. $out->outputText( "Finished uploading files: $msg\n" );
Member Variables
|
protected array(bool=>int) |
$counter
= array( true => 0, false => 0, )
Counter for success and failure outputs. |
|
protected array(string=>string) |
$options
= array( 'successChar' => '+', // Char to indicate success 'failureChar' => '-', // Char to indicate failure )
Options |
|
protected ezcConsoleOutput |
$outputHandler
The ezcConsoleOutput object to use. |
Method Summary
|
public ezcConsoleStatusbar |
__construct(
$outHandler, [$options = array()], $settings )
Creates a new status bar. |
|
public void |
add(
$status )
Add a status to the status bar. |
|
public int |
getFailureCount(
)
Returns number of failures during the run. |
|
public int |
getSuccessCount(
)
Returns number of successes during the run. |
|
public void |
reset(
)
Reset the state of the statusbar object to its initial one. |
|
public void |
setOptions(
$options )
Set options. |
|
public mixed |
__get(
$key )
Property read access. |
|
public bool |
__isset(
$key )
Property isset access. |
|
public void |
__set(
$key, $val )
Property write access. |
Methods
__construct
ezcConsoleStatusbar __construct(
ezcConsoleOutput
$outHandler, [
$options = array()], array(string=>string)
$settings )
Creates a new status bar.
Parameters
| Name |
Type |
Description |
$outHandler |
ezcConsoleOutput |
Handler to utilize for output |
$settings |
array(string=>string) |
Settings |
$options |
array(string=>string) |
Options |
See also:
ezcConsoleStatusbar::$options.
add
void add(
bool
$status )
Add a status to the status bar.
Adds a new status to the bar which is printed immediatelly. If the cursor is currently not at the beginning of a line, it will move to the next line.
Parameters
| Name |
Type |
Description |
$status |
bool |
Print successChar on true, failureChar on false. |
getFailureCount
int getFailureCount(
)
Returns number of failures during the run.
Returns the number of failure characters printed from this status bar.
getSuccessCount
int getSuccessCount(
)
Returns number of successes during the run.
Returns the number of success characters printed from this status bar.
reset
void reset(
)
Reset the state of the statusbar object to its initial one.
setOptions
void setOptions(
$options )
Set options.
Set the options of the statusbar.
Parameters
| Name |
Type |
Description |
$options |
array(string=>string) |
The optiosn to set. |
See also:
ezcConsoleStatusbar::$options.
__get
mixed __get(
string
$key )
Property read access.
Parameters
| Name |
Type |
Description |
$key |
string |
Name of the property. |
Throws
| Class | Description |
ezcBasePropertyNotFoundException |
If the the desired property is not found. |
__isset
bool __isset(
string
$key )
Property isset access.
Parameters
| Name |
Type |
Description |
$key |
string |
Name of the property. |
__set
void __set(
string
$key, mixed
$val )
Property write access.
Parameters
| Name |
Type |
Description |
$key |
string |
Name of the property. |
$val |
mixed |
The value for the property. |
Throws
| Class | Description |
ezcBasePropertyNotFoundException |
If a desired property could not be found. |
ezcBaseValueException |
If a desired property value is out of range. |
Last updated: Fri, 02 Nov 2007