You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
*`$times` specifies how many times the operation may be called.
26
26
*`$operation` is a callback to be run up to the specified number of times.
27
+
*`$onError` is called immediately before retrying the operation.
27
28
28
-
Note that in the [original library](https://github.com/igorw/retry), `$times` specified the number of *retries* and therefore the operation could run up to `n + 1` times. In this version, `$times` specifies exactly the number of times the operation may run such that if zero (`0`) is specified it will never run.
29
+
Note that in the [original library](https://github.com/igorw/retry), `$times` specified the number of *retries* and
30
+
therefore the operation could run up to `n + 1` times. In this version, `$times` specifies exactly the number of
31
+
times the operation may run such that if zero (`0`) is specified it will never run.
29
32
30
33
### Example
31
34
35
+
The following code fragment attempts to fetch data from a URL over HTTP up to five times.
36
+
32
37
```php
33
38
use function ScriptFUSION\Retry\retry;
34
39
35
-
// Try an operation up to 5 times.
36
40
$response = retry(5, function () use ($url) {
37
41
return HttpConnector::fetch($url);
38
42
});
@@ -47,4 +51,3 @@ $response = retry(5, function () use ($url) {
0 commit comments