I would like to insert the following code:
if ($this->id == null) {
return false;
}
in several methods of a class. I coulde use include("mycode.php') to do so, but it’s pretty ugly.
Is there a way to do it calling a function (so it will return false in an higher scope) ?
This looks like an instance of DRY gone way too far.
It’s just three lines – the amount of code saved is minimal.
And from a maintenance point of view, these three lines are crucial for understanding what the function does. Moving this part of flow control into an include is a terrible idea.