22=====
33
44[ ![ Latest version] [ Version image ]] [ Releases ]
5+ [ ![ Total downloads] [ Downloads image ]] [ Downloads ]
56[ ![ Build status] [ Build image ]] [ Build ]
67[ ![ Test coverage] [ Coverage image ]] [ Coverage ]
78[ ![ Code style] [ Style image ]] [ Style ]
@@ -19,15 +20,17 @@ Requirements
1920Usage
2021-----
2122
22- The ` retry ` function retries an operation up to the specified number of times with an optional error handler and has
23- the following signature.
23+ The ` retry ` function retries an operation up to the specified number of times with an optional exception handler.
24+
25+ If an exception handler is specified, it is called immediately before retrying the operation. If the handler returns
26+ ` false ` , the operation is not retried.
2427
2528```
2629retry(int $times, callable $operation, callable $onError = null);
2730```
2831* ` $times ` &mdash ; Maximum number of times the operation may run.
2932* ` $operation ` &mdash ; Operation to run up to the specified number of times.
30- * ` $onError ` &mdash ; Optional. Error handler called immediately before retrying the operation .
33+ * ` $onError ` &mdash ; Optional. Exception handler that receives the thrown exception as its first argument .
3134
3235Note in the original library, ` $times ` specifies the number of * retries* and therefore the operation could run up to
3336` $times + 1 ` times. In this version, ` $times ` specifies exactly the number of times the operation may run such that if
@@ -48,6 +51,8 @@ $response = retry(5, function () use ($url) {
4851
4952 [ Releases ] : https://github.com/ScriptFUSION/Retry/releases
5053 [ Version image ] : https://poser.pugx.org/scriptfusion/retry/v/stable " Latest version "
54+ [ Downloads ] : https://packagist.org/packages/scriptfusion/retry
55+ [ Downloads image ] : https://poser.pugx.org/scriptfusion/retry/downloads " Total downloads "
5156 [ Build ] : http://travis-ci.org/ScriptFUSION/Retry
5257 [ Build image ] : https://travis-ci.org/ScriptFUSION/Retry.svg " Build status "
5358 [ Coverage ] : https://coveralls.io/github/ScriptFUSION/Retry
0 commit comments