From cf827ca8f28a5684b5e67957522378f533407a22 Mon Sep 17 00:00:00 2001 From: Vincent Vanwaelscappel Date: Mon, 21 Aug 2023 17:35:49 +0200 Subject: [PATCH] wip #6202 @0.25 --- src/PHP.php | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/src/PHP.php b/src/PHP.php index 3a86f42..bed218a 100644 --- a/src/PHP.php +++ b/src/PHP.php @@ -77,4 +77,16 @@ class PHP if ($return) return $export; else echo $export; } + + public static function retryOnError(callable $callback, $attempts = 3) + { + try { + return call_user_func($callback); + } catch (\Exception $e) { + if ($attemps > 0) { + return self::retryOnError($callback, $attempts - 1); + } + throw $e; + } + } } -- 2.39.5