7 * This source file is subject to the new BSD license that is bundled
8 * with this package in the file LICENSE.txt.
9 * It is also available through the world-wide-web at this URL:
10 * http://framework.zend.com/license/new-bsd
11 * If you did not receive a copy of the license and are unable to
12 * obtain it through the world-wide-web, please send an email
13 * to license@zend.com so we can send you a copy immediately.
16 * @package Zend_ProgressBar
17 * @copyright Copyright (c) 2005-2009 Zend Technologies USA Inc. (http://www.zend.com)
18 * @license http://framework.zend.com/license/new-bsd New BSD License
23 * Abstract class for Zend_ProgressBar_Adapters
26 * @package Zend_ProgressBar
27 * @copyright Copyright (c) 2005-2009 Zend Technologies USA Inc. (http://www.zend.com)
28 * @license http://framework.zend.com/license/new-bsd New BSD License
30 abstract class Zend_ProgressBar_Adapter
33 * Option keys to skip when calling setOptions()
37 protected $_skipOptions = array(
43 * Create a new adapter
45 * $options may be either be an array or a Zend_Config object which
46 * specifies adapter related options.
48 * @param null|array|Zend_Config $options
50 public function __construct($options = null)
52 if (is_array($options)) {
53 $this->setOptions($options);
54 } elseif ($options instanceof Zend_Config
) {
55 $this->setConfig($options);
60 * Set options via a Zend_Config instance
62 * @param Zend_Config $config
63 * @return Zend_ProgressBar_Adapter
65 public function setConfig(Zend_Config
$config)
67 $this->setOptions($config->toArray());
73 * Set options via an array
75 * @param array $options
76 * @return Zend_ProgressBar_Adapter
78 public function setOptions(array $options)
80 foreach ($options as $key => $value) {
81 if (in_array(strtolower($key), $this->_skipOptions
)) {
85 $method = 'set' . ucfirst($key);
86 if (method_exists($this, $method)) {
87 $this->$method($value);
95 * Notify the adapter about an update
97 * @param float $current Current progress value
98 * @param float $max Max progress value
99 * @param float $percent Current percent value
100 * @param integer $timeTaken Taken time in seconds
101 * @param integer $timeRemaining Remaining time in seconds
102 * @param string $text Status text
105 abstract public function notify($current, $max, $percent, $timeTaken, $timeRemaining, $text);
108 * Called when the progress is explicitly finished
112 abstract public function finish();