Fluent Function

../_images/fluent_function.png

A fluent interface allows the chaining of method calls. It is a bit harder to do with functions, as there is no supporting object, but it is possible.

Returning __FUNCTION__ allows the subsequent call of the same function.

Returning a closure of itself is also possible, yet a bit more cumbersome, as __FUNCTION__ is not recognized as a string for a function call.

Thanks to Andreas Heigl for the inspiration.

See Also

PHP Features