/** * Update the progressbar * * @param float $value * @param string $text * @return void */ public function update($value = null, $text = null) { // Update value if given if ($value !== null) { $this->_current = min($this->_max, max($this->_min, $value)); } // Update text if given if ($text !== null) { $this->_statusText = $text; } // See if we have to update a namespace if ($this->_persistenceNamespace !== null) { $this->_persistenceNamespace->current = $this->_current; $this->_persistenceNamespace->statusText = $this->_statusText; } // Calculate percent if ($this->_min === $this->_max) { $percent = false; } else { $percent = (double) ($this->_current - $this->_min) / ($this->_max - $this->_min); } // Calculate ETA $timeTaken = time() - $this->_startTime; if ($percent === 0.0 || $percent === false) { $timeRemaining = null; } else { $timeRemaining = round(1 / $percent * $timeTaken - $timeTaken); } // Poll the adapter $this->_adapter->notify($this->_current, $this->_max, $percent, $timeTaken, $timeRemaining, $this->_statusText); }