Using chaining without discrimination just for some subjective expressiveness should be considered a clear anti-pattern.

On the business domains, patterns like DDD advocate immutability which chaining violates since you are returning a modified $this.

You could chain, as long as you return a copy with modifications, rather than $this.

The ORM example is not relevant in other contexts because it was meant to define a language. You expect the behavior, but it is a very particular area of the application with very particular needs (you do need to build on the statement largely as a one time operation to provide a given result and never care about intermediates)

I would recommend reading a bit into ddd, value objects and the design patterns around that.


Love podcasts or audiobooks? Learn on the go with our new app.

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store