File indexing completed on 2024-12-22 05:36:57
0001 <?php 0002 /** 0003 * Zend Framework 0004 * 0005 * LICENSE 0006 * 0007 * This source file is subject to the new BSD license that is bundled 0008 * with this package in the file LICENSE.txt. 0009 * It is also available through the world-wide-web at this URL: 0010 * http://framework.zend.com/license/new-bsd 0011 * If you did not receive a copy of the license and are unable to 0012 * obtain it through the world-wide-web, please send an email 0013 * to license@zend.com so we can send you a copy immediately. 0014 * 0015 * @category Zend 0016 * @package Zend_ProgressBar 0017 * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com) 0018 * @license http://framework.zend.com/license/new-bsd New BSD License 0019 * @version $Id$ 0020 */ 0021 0022 /** 0023 * Abstract class for Zend_ProgressBar_Adapters 0024 * 0025 * @category Zend 0026 * @package Zend_ProgressBar 0027 * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com) 0028 * @license http://framework.zend.com/license/new-bsd New BSD License 0029 */ 0030 abstract class Zend_ProgressBar_Adapter 0031 { 0032 /** 0033 * Option keys to skip when calling setOptions() 0034 * 0035 * @var array 0036 */ 0037 protected $_skipOptions = array( 0038 'options', 0039 'config', 0040 ); 0041 0042 /** 0043 * Create a new adapter 0044 * 0045 * $options may be either be an array or a Zend_Config object which 0046 * specifies adapter related options. 0047 * 0048 * @param null|array|Zend_Config $options 0049 */ 0050 public function __construct($options = null) 0051 { 0052 if (is_array($options)) { 0053 $this->setOptions($options); 0054 } elseif ($options instanceof Zend_Config) { 0055 $this->setConfig($options); 0056 } 0057 } 0058 0059 /** 0060 * Set options via a Zend_Config instance 0061 * 0062 * @param Zend_Config $config 0063 * @return Zend_ProgressBar_Adapter 0064 */ 0065 public function setConfig(Zend_Config $config) 0066 { 0067 $this->setOptions($config->toArray()); 0068 0069 return $this; 0070 } 0071 0072 /** 0073 * Set options via an array 0074 * 0075 * @param array $options 0076 * @return Zend_ProgressBar_Adapter 0077 */ 0078 public function setOptions(array $options) 0079 { 0080 foreach ($options as $key => $value) { 0081 if (in_array(strtolower($key), $this->_skipOptions)) { 0082 continue; 0083 } 0084 0085 $method = 'set' . ucfirst($key); 0086 if (method_exists($this, $method)) { 0087 $this->$method($value); 0088 } 0089 } 0090 0091 return $this; 0092 } 0093 0094 /** 0095 * Notify the adapter about an update 0096 * 0097 * @param float $current Current progress value 0098 * @param float $max Max progress value 0099 * @param float $percent Current percent value 0100 * @param integer $timeTaken Taken time in seconds 0101 * @param integer $timeRemaining Remaining time in seconds 0102 * @param string $text Status text 0103 * @return void 0104 */ 0105 abstract public function notify($current, $max, $percent, $timeTaken, $timeRemaining, $text); 0106 0107 /** 0108 * Called when the progress is explicitly finished 0109 * 0110 * @return void 0111 */ 0112 abstract public function finish(); 0113 }