I want to avoid using multiples return in my functions, but I can't see how to interrupt them without adding a lot of else in a case like this :
public function foo($number)
{
if ($number > 8)
{
return ' > 8';
}
if (exist($number))
{
return $number . ' exist';
}
return $this->bar($number);
}
My use case is to display an error message for some invalid cases and don't execute what's left in the function.
foo()is doing a bit too much; returning error messages or the result of a separate database operation does not sound very logical and would be hard to process by whatever calls that method.bar()). I should split that function. Thanks !