src/Helper.php
public static function retry($times, callable $callback, $sleep = 0)
    {
        $times--;

        beginning:
        try {
            return $callback();
        } catch (\Exception $e) {
            if (! $times) {
                throw $e;
            }

            $times--;

            if ($sleep) {
                usleep($sleep * 1000);
            }

            goto beginning;
        }
    }
public static function retry($times, callable $callback, $sleep = 0)
    {
        $times--;

        beginning:
        try {
            return $callback();
        } catch (\Exception $e) {
            if (! $times) {
                throw $e;
            }

            $times--;

            if ($sleep) {
                usleep($sleep * 1000);
            }

            goto beginning;
        }
    }
public static function retry ( $ times , callable $ callback , $ sleep = 0 ) { $ times -- ; beginning : try { return $ callback ( ) ; } catch ( \ Exception $ e ) { if ( ! $ times ) { throw $ e ; } $ times -- ; if ( $ sleep ) { usleep ( $ sleep * 1000 ) ; } goto beginning ; } }
Retry an operation a given number of times.

@param  int  $times
@param  callable  $callback
@param  int  $sleep
@return mixed

@throws \Exception
Retry an operation a given number of times .