Skip to content

Adding filterByRegex method to Laravel Collections #55147

Discussion options

You must be logged in to vote

Hey @mohammadrasoulasghari, I would have it as a separate function, as per your suggestion.

JavaScript takes both a string and a regular expression on some String methods (replace(), match(), ...), and more often than not I had to explain the difference of using each to new developers. I guess if there were different methods, it could be somehow easier to spot the difference.

In JavaScript-land, one could argue those ambiguities don't happen, as regular expressions have their own delimiters, but in PHP, that is not the case.

I also think that the lesser a method does, its intent is clearer, and it is easier to test.

And, IMHO, the more execution paths a function has, the more prone to bug…

Replies: 1 comment 10 replies

Comment options

You must be logged in to vote
10 replies
@mohammadrasoulasghari
Comment options

@shaedrich
Comment options

@mohammadrasoulasghari
Comment options

@rodrigopedra
Comment options

Answer selected by mohammadrasoulasghari
@mohammadrasoulasghari
Comment options

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Ideas
Labels
None yet
5 participants