8000 Feature: doesntStartWith() and doesntEndWith() string methods by balboacodes · Pull Request #56168 · laravel/framework · GitHub
[go: up one dir, main page]

Skip to content

Feature: doesntStartWith() and doesntEndWith() string methods #56168

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

Merged

Conversation

balboacodes
Copy link
Contributor
@balboacodes balboacodes commented Jun 29, 2025

This pull request adds doesntStartWith() and doesntEndWith() methods to the Illuminate\Support\Str and Illuminate\Support\Stringable helper classes. It acts as a simple negation for the startsWith() and endsWith() methods without having to use something like ! Str::startsWith() or ! Str::endsWith(), which aligns with the existing Str::doesntContain() method.

@shaedrich
Copy link
Contributor
shaedrich commented Jun 29, 2025

Ironically, that's longer than just using the ! 😂

Also, when adding a doesntEndWith() and talking of alignment, why don't you add a doesntStartWith() method as well?

@balboacodes
Copy link
Contributor Author

Ironically, that's longer than just using the ! 😂

Also, when adding a doesntEndWith() and talking of alignment, why don't you add a doesntStartWith() method as well?

Yeah, it's longer than using !, but the point is to add a fluent method that is similar to what's already available in the Str class (the Collection class also has methods like this).

I agree with the second point though. For completeness, a doesntStartWith() method should also be added. I'm happy to add this to the PR.

@balboacodes balboacodes marked this pull request as draft June 30, 2025 22:13
@balboacodes balboacodes deleted the feature-doesnt-end-with-string-methods branch June 30, 2025 22:46
@balboacodes balboacodes restored the feature-doesnt-end-with-string-methods branch June 30, 2025 22:49
@balboacodes balboacodes reopened this Jun 30, 2025
@balboacodes balboacodes marked this pull request as ready for review June 30, 2025 22:53
@balboacodes balboacodes changed the title Feature: doesntEndWith string method Feature: doesntStartWith() and doesntEndWith() string methods Jun 30, 2025
@taylorotwell taylorotwell merged commit e6245ae into laravel:12.x Jul 1, 2025
119 checks passed
@balboacodes
Copy link
Contributor Author

@taylorotwell would you like me to create a PR to the docs repo for these new methods?

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
0