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

[String] Add kebab() to methods to change case #48780

Closed
seb-jean opened this issue Dec 23, 2022 · 12 comments · Fixed by #58385
Closed

[String] Add kebab() to methods to change case #48780

seb-jean opened this issue Dec 23, 2022 · 12 comments · Fixed by #58385

Comments

@seb-jean
Copy link
Contributor

Description

Hi,

It would be interesting to add the kebab() function to the string component.

Example

u('FOO Bar')->kebab();     // 'foo-bar'
@seb-jean seb-jean changed the title [String] Add kebab to methods to Change Case [String] Add kebab() to methods to Change Case Dec 23, 2022
@GromNaN
Copy link
Member

GromNaN commented Dec 23, 2022

This transformation looks like the slug. Except it doesn't translate special chars to ascii.
What is the use-case for kebab transformation?

@seb-jean
Copy link
Contributor Author

seb-jean commented Dec 23, 2022

I have a form name that is in snake case. I would like it to be in kebab case automatically.
This is for use in Twig.

@GromNaN
Copy link
Member

GromNaN commented Dec 23, 2022

Great. We already have camel and snake, adding kebab seems reasonable. Do you want to make a PR?

@seb-jean
Copy link
Contributor Author

I will try

@OskarStark OskarStark changed the title [String] Add kebab() to methods to Change Case [String] Add kebab() to methods to change case Jan 6, 2023
@carsonbot
Copy link

Thank you for this suggestion.
There has not been a lot of activity here for a while. Would you still like to see this feature?

@carsonbot
Copy link

Could I get a reply or should I close this?

@ghost
Copy link

ghost commented Aug 8, 2023

Miss this feature as well.

@carsonbot carsonbot removed the Stalled label Aug 8, 2023
@janisint
Copy link

janisint commented Aug 21, 2023

+1. Would like to see this.

@donaldinou
Copy link

Why not seems fair?

@jdreesen
Copy link
Contributor

As long as it doesn't exist, you can use snake()->replace('_', '-') instead.

@ReSpawN
Copy link

ReSpawN commented Sep 24, 2024

+1, weird that it still haven't been PR'd. Need help with this?

@jdreesen
Copy link
Contributor

There was a PR: #48781

@fabpot fabpot closed this as completed Sep 30, 2024
fabpot added a commit that referenced this issue Sep 30, 2024
…xandre-daubois)

This PR was merged into the 7.2 branch.

Discussion
----------

[String] Add the `AbstractString::kebab()` method

| Q             | A
| ------------- | ---
| Branch?       | 7.2
| Bug fix?      | no
| New feature?  | yes
| Deprecations? | no
| Issues        | Fix #48780
| License       | MIT

Supersedes #48781. It seems there's quite a demand for this feature. I think it is a nice DX improvement which also helps readability over calling `snake()->replace('_', '-')`.

Commits
-------

b2b82d6 [String] Add the `AbstractString::kebab()` method
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
9 participants