I have the following pattern of code in a lot of methods:
$attempts = 0;
do {
$response = $this->DOSOMETHIING($data, $info);
sleep(1);
$attempts++;
} while ($attempts < 5);
What I would like to do is have a helper method for this while loop that can somehow be sent a specific method call. So something like this:
$response = $this->execute($this->DOSOMETHIING($data, $info));
The helper method:
function execute($method){
$attempts = 0;
do {
$response = $method(); <<< I know!
sleep(1);
$attempts++;
} while ($attempts < 5);
return $response;
}
The trouble is that the method call being sent to the helper method will be one of 3 different method calls and they all have a different number of parameters, so it's not like I can send the method and the parameters separately.