src/MakesHttpRequests.php
public function retry($timeout, $callback)
    {
        $start = time();

        beginning:

        if ($output = $callback()) {
            return $output;
        }

        if (time() - $start < $timeout) {
            sleep(5);

            goto beginning;
        }

        throw new TimeoutException($output);
    }
public function retry($timeout, $callback)
    {
        $start = time();

        beginning:

        if ($output = $callback()) {
            return $output;
        }

        if (time() - $start < $timeout) {
            sleep(5);

            goto beginning;
        }

        throw new TimeoutException($output);
    }
public function retry ( $ timeout , $ callback ) { $ start = time ( ) ; beginning : if ( $ output = $ callback ( ) ) { return $ output ; } if ( time ( ) - $ start < $ timeout ) { sleep ( 5 ) ; goto beginning ; } throw new TimeoutException ( $ output ) ; }
Retry the callback or fail after x seconds.

@param  integer $timeout
@param  callable $callback
@return mixed
Retry the callback or fail after x seconds .