OK. I get a code smell warning in my IDE. I understand why, and understand that the warning isn't especially dire. However, if there is a better way to write this block, I would like to know.
public function factory($state_name = 'Generic')
{
...
try {
if (!$class_exists) {
throw new CustomException;
} else {
return new $class_name;
}
}
catch (CustomException $c) {
echo ...
}
}
I don't return a value outside of the try
block. Smell goes away if I return one at the end. Is there a better way to do this?