Adding try/catch to Laravel collections
Today, JMac and I did streamed a code pairing session. Our goal was to add a try/catch methods to Laravels collection class.
Basically we we try to make JMac's dream, that he tweeted a few days ago, come true.
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
Here's a recording of our stream.
JMac and I are going to polish it a bit more, add some test coverage, and PR it Laravel soon.
EDIT: here is the stream that JMac and I did the day after polishing the PR.
And this is the PR submitted to Laravel.
What are your thoughts on "Adding try/catch to Laravel collections"?