[ZF-6295] Generic:
[zend.git] / library / Zend / ProgressBar / Adapter.php
blob3f39de9c74ac05a8d03d005b8df97a850252315d
1 <?php
2 /**
3 * Zend Framework
5 * LICENSE
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.
15 * @category Zend
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
19 * @version $Id$
22 /**
23 * Abstract class for Zend_ProgressBar_Adapters
25 * @category Zend
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
32 /**
33 * Option keys to skip when calling setOptions()
35 * @var array
37 protected $_skipOptions = array(
38 'options',
39 'config',
42 /**
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);
59 /**
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());
69 return $this;
72 /**
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)) {
82 continue;
85 $method = 'set' . ucfirst($key);
86 if (method_exists($this, $method)) {
87 $this->$method($value);
91 return $this;
94 /**
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
103 * @return void
105 abstract public function notify($current, $max, $percent, $timeTaken, $timeRemaining, $text);
108 * Called when the progress is explicitly finished
110 * @return void
112 abstract public function finish();