Dynamic method calling in PHP using variables
A very naive yet effective approach on metaprogramming that helps you dynamically call the right method in a very concise manner.
$method = $user instance of User ? 'save' : 'saveMany';
$this->members()->$method($user);
The example is an excerpt from a dummy Laravel app.