Conditions | 4 |
Paths | 3 |
Total Lines | 25 |
Code Lines | 12 |
Lines | 0 |
Ratio | 0 % |
Tests | 10 |
CRAP Score | 4 |
Changes | 0 |
1 | <?php |
||
14 | 8 | public function executeFunction($pureFunction, $maxRetries, array $arguments = []) |
|
15 | { |
||
16 | 8 | $retries = -1; |
|
17 | do { |
||
18 | try { |
||
19 | |||
20 | /** |
||
21 | * The real function call |
||
22 | */ |
||
23 | 8 | return call_user_func_array($pureFunction, $arguments); |
|
24 | |||
25 | 3 | } catch (ConcurrentModificationException $e) { |
|
26 | |||
27 | 2 | $retries++; |
|
28 | 2 | if ($retries >= $maxRetries) { |
|
29 | 1 | break; |
|
30 | } |
||
31 | |||
32 | 2 | continue;//retry |
|
33 | } |
||
34 | |||
35 | 2 | } while (true); |
|
36 | |||
37 | 1 | throw new TooManyCommandExecutionRetries(sprintf("TooManyCommandExecutionRetries: %d (%s)", $retries, $e->getMessage())); |
|
38 | } |
||
39 | } |