*/ protected $_nextStep = NULL; /** * Provide current step here * @param int $step */ function __construct($step = 0) { if (empty($step)) { $step = 0; } $this->_step = intval($step); } /** * Register steps (function names) */ public function registerSteps() { $args = func_get_args(); $this->_steps = array_merge($this->_steps, $args); } /** * Returns current step * @return int */ public function getStep() { return $this->_step; } /** * Returns next step * @return int */ public function getNextStep() { return !is_null($this->_nextStep)? $this->_nextStep : $this->_step += 1; } /** * Sets current step * @param int $num */ public function setStep($num) { $this->_step = intval($num); } /** * Forcing next step * @param int $num */ public function setNextStep($num) { $this->_nextStep = intval($num); } /** * Calculates bar width * @return int Should be used as percentage width (%) */ public function barWidth() { return round(($this->_step*100)/count($this->_steps)); } /** * Calls current step's function * @return mixed */ public function init() { if ($this->_step !== 0 && isset($this->_steps[$this->_step]) && is_callable($this->_steps[$this->_step])) { return call_user_func_array($this->_steps[$this->_step], array($this->_step, $this)); } } /** * Returns initial HTML formatted screen * @param string $message Message to be displayed * @return string */ public function render($message = '') { $output = '
' . $message . '
'; return $output; } }