private function toReanimationPolicy($policy)
{
if (is_integer($policy)) {
return function ($status, $attempts, $stdout, $stderr) use($policy) {
return $policy >= $attempts;
};
}
if (is_bool($policy)) {
return function ($status, $attempts, $stdout, $stderr) use($policy) {
return $policy;
};
}
if (is_callable($policy)) {
return $policy;
}
throw new InvalidArgumentException("'{$policy}' could not be converted to a reanimation policy");
}