Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[8.x] Add new Stringable::test method #36462

Merged
merged 4 commits into from
Mar 4, 2021
Merged

[8.x] Add new Stringable::test method #36462

merged 4 commits into from
Mar 4, 2021

Conversation

ryangjchandler
Copy link
Contributor

@ryangjchandler ryangjchandler commented Mar 4, 2021

This pull request introduces a new Stringable::test method that checks whether the string matches a particular pattern, but doesn't return the match(es).

This is essentially just a shortcut for $stringable->match('//')->isNotEmpty() but something that I do often enough, and also macro, that it warranted a pull request to the core.

@ryangjchandler
Copy link
Contributor Author

I realise now that matches might get confused with matchAll, perhaps another good method name would be test, just like JavaScript's method.

@taylorotwell
Copy link
Member

Yeah, maybe test would be good since that is what JavaScript calls it.

@ryangjchandler
Copy link
Contributor Author

@taylorotwell All done. 🤟

@ryangjchandler ryangjchandler changed the title [8.x] Add new Stringable::matches method [8.x] Add new Stringable::test method Mar 4, 2021
@taylorotwell taylorotwell merged commit 34418f3 into laravel:8.x Mar 4, 2021
@ryangjchandler ryangjchandler deleted the feature/str-matches-function branch March 4, 2021 14:15
@foremtehan
Copy link
Contributor

Can we have it on Illuminate\Support\Str too?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants