Adding try/catch to Laravel collections original
A few weeks ago, Jmac tweeted out an excellent idea. What if we could use try and catch in a collection chain?
Collections are the jam. Yet they leave me dreaming of more.
— Jason McCreary (@gonedark) June 1, 2020
Take this block that performs some custom validation logic by leveraging a value object constructor.
Collections definitely streamline it, but what if I could also chain the exception handling… 🔥 pic.twitter.com/4jj0uFgwWb
Meanwhile, Jmac and I did a few code pairing sessions to work on a possible implementation. We've added try and catch methods to the laravel-collection-macros package.
In this blog post, I'd like to share what you can do with these methods and how they work under the hood.
