Apache Zeta Components Manual :: File Source for statusbar.php
Source for file statusbar.php
Documentation is available at statusbar.php
* File containing the ezcConsoleStatusbar class.
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The ASF licenses this file
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
* http://www.apache.org/licenses/LICENSE-2.0
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* @version //autogentag//
* @license http://www.apache.org/licenses/LICENSE-2.0 Apache License, Version 2.0
* Creating and maintaining status-bars to be printed to the console.
* $status = new ezcConsoleStatusbar( new ezcConsoleOutput() );
* $status->options['successChar'] = '*';
* foreach ( $files as $file )
* $res = $file->upload();
* // Add status if form of bool true/false to statusbar.
* $status->add( $res ); // $res is true or false
* // Retreive and display final statusbar results
* $msg = $status->getSuccess() . ' succeeded, ' . $status->getFailure() . ' failed.';
* $out->outputText( "Finished uploading files: $msg\n" );
* @property ezcConsoleStatusbarOptions $options
* Contains the options for this class.
* Container to hold the properties
* @var array(string=>mixed)
* The ezcConsoleOutput object to use.
* Counter for success and failure outputs.
* Creates a new status bar.
* @param ezcConsoleOutput $outHandler Handler to utilize for output
* @param array(string=>string) $options Options
* @see ezcConsoleStatusbar::$options
public function __construct( ezcConsoleOutput $outHandler, array $options =
array() )
* @param string $key Name of the property.
* @return mixed Value of the property or null.
* @throws ezcBasePropertyNotFoundException
* If the the desired property is not found.
public function __get( $key )
if ( isset
( $this->properties['options']->$key ) )
* This method allows you to change the options of a statusbar.
* @param array(string=>string)|ezcConsoleOutputOptions$options The options to set.
* @throws ezcBaseSettingNotFoundException
* If you tried to set a non-existent option value.
* @throws ezcBaseSettingValueException
* If the value is not valid for the desired option.
* @throws ezcBaseValueException
* If you submit neither an array nor an instance of
* ezcConsoleOutputOptions.
* @param string $key Name of the property.
* @param mixed $val The value for the property.
* @throws ezcBasePropertyNotFoundException
* If a desired property could not be found.
* @throws ezcBaseValueException
* If a desired property value is out of range.
public function __set( $key, $val )
// Those two are here for BC reasons only, it is proper to
// use $statusbar->options->successChar instead of just
// $statusbar->successChar.
// No checks necessary here, already performed in
// ezcConsoleStatusbarOptions
* @param string $key Name of the property.
* @return bool True is the property is set, otherwise false.
public function __isset( $key )
* Returns the current options.
* Returns the options currently set for this progressbar.
* @return ezcConsoleStatusbarOptions The current options.
* Add a status to the status bar.
* Adds a new status to the bar which is printed immediately. If the
* cursor is currently not at the beginning of a line, it will move to
* @param bool $status Print successChar on true, failureChar on false.
public function add( $status )
if ( is_bool( $status ) ===
false )
$status = (bool)
$status;
* Reset the state of the status-bar object to its initial one.
foreach ( $this->counter as $status =>
$count )
* Returns number of successes during the run.
* Returns the number of success characters printed from this status bar.
* @return int Number of successes.
* Returns number of failures during the run.
* Returns the number of failure characters printed from this status bar.
* @return int Number of failures.