getScenarios() as $nextScenario) { if ($nextScenario->getLine() > $step->getLine()) { break; } $scenario = $nextScenario; } return $scenario; } /** * Retry until no exceptions are thrown, or until * $timeout seconds are reached. * * If timeout reached, re-throws the first exception. * * @param callable $callback * @param int $timeout * @return mixed * @throws Exception */ protected function retryThrowable($callback, $timeout = 3) { $firstEx = null; do { try { return call_user_func($callback); } catch (Exception $ex) { if (!$firstEx) { $firstEx = $ex; } } sleep(1); } while (--$timeout >= 0); throw $firstEx; } }