What's the reason not to simplify some functions in the core?
PermalinkHere's a snippet of code from the core (Concrete\Core\Page)
public static function getCurrentPage() { $req = Request::getInstance(); $current = $req->getCurrentPage(); return $current; }
What is the advantage of splitting the code up into separate parts rather than combining it into one line, like this:
public static function getCurrentPage() { return Request::getInstance()->getCurrentPage(); }
Both approaches, if taken to an extreme, lead to unnecessary obscurity.
The method chaining approach breaks down when something in the middle of a chain could return null (and hence a test is needed whether to continue). Typical are foreach on null errors.
I have been called on that recently so I know it's frowned upon but old habits die hard.
I am also not aware of any "technical" benefit of doing it this way or the other. I think it's just a matter of preference.