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

feat(support): add Pluralizer implementation #418

Merged
merged 2 commits into from
Sep 18, 2024

Conversation

innocenzi
Copy link
Member

@innocenzi innocenzi commented Sep 18, 2024

This pull request adds support for pluralizing (or singularizing) nouns through doctrine/inflector. The implementation is a simplified and cleaner version of Laravel's.

This can be used as a helper in application code through LanguageHelpers::pluralize(), but is also intended to be used in the framework itself, such as in database table names, exception and log messages, validation, etc.

Note: I didn't know if I should make a new package or put it in the support one, so I kept things simple and added it to Support. I'm assuming Support will grow over time and it's not a bad place to have it, but at the same time, Clock is a separate package, so I don't know. Happy to update the PR.

Related: https://discord.com/channels/1236153076688359495/1236153079603269766/1268515847073173606

@coveralls
Copy link

coveralls commented Sep 18, 2024

Pull Request Test Coverage Report for Build 10914752438

Details

  • 0 of 0 changed or added relevant lines in 0 files are covered.
  • No unchanged relevant lines lost coverage.
  • Overall coverage increased (+0.02%) to 78.016%

Totals Coverage Status
Change from base Build 10902941807: 0.02%
Covered Lines: 4372
Relevant Lines: 5604

💛 - Coveralls

@aidan-casey
Copy link
Member

Thanks, @innocenzi! This is definitely a good thing to have in the framework, I cannot tell you how many times I have reached for this in Laravel.

What does this implementation do with the words Laravel deems as "uncountable"?

@innocenzi
Copy link
Member Author

Currently, it ignores them because I wanted to keep things simple. I was thinking we could add them back later if needed.

I checked why Laravel had these exceptions and stumbled upon these—it seems they were added a long time ago as an edge case:

I personally think we don't even need to add them, since words like that are quite common and we should instead manually override the table name through the framework.

@aidan-casey
Copy link
Member

Agreed. Thank you for the thorough discovery. 🙂

@aidan-casey aidan-casey merged commit 32fb3e9 into tempestphp:main Sep 18, 2024
12 checks passed
@innocenzi innocenzi deleted the feat/pluralizer branch September 18, 2024 03:22
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