_repititions; } /** * Set number of repititions * * @param integer $repititions * @return E7_Tools_RetryProxy (fluent interface) */ public function setRepititions($repititions) { $this->_repititions = $repititions; return $this; } /** * Retrieve delay in seconds * * @return integer */ public function getDelay() { return $this->_delay; } /** * Set delay in seconds * * @param integer $delay * @return E7_Tools_RetryProxy (fluent interface) */ public function setDelay($delay) { $this->_delay = $delay; return $this; } /** * Proxy-Method passes all calls including parameters * * @param string $callback * @param [...] mixed * @return mixed * @throws Exception */ public function call($callback) { $exception = null; $count = 0; $args = func_get_args(); array_shift($args); do { try { return call_user_func_array($callback, $args); } catch (Exception $e) { $exception = $e; sleep($this->getDelay()); } } while ($this->getRepititions() > $count++); if ($exception instanceof Exception) { throw $exception; } } }