Skip to content

Conversation

@seb-jean
Copy link
Contributor

Q A
Branch? 6.3
Bug fix? no
New feature? yes
Deprecations? no
Tickets Fix #48780
License MIT
Doc PR n/a

I add suport for kebab case for String Component.


public function kebab(): static
{
$str = $this->camel();
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

camel()->lower()->replace('_', '-')

Is not enough? Just asking

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If that's the case, maybe we don't need yet another method?

Copy link
Contributor Author

@seb-jean seb-jean Dec 31, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

camel()->lower()->replace('_', '-')

Is not enough? Just asking

Your example does not work.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Right, it's snake()->replace('_', '-'), I think.

return $this->string;
}

abstract public function kebab(): static;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

AbstractString is not @internal, so this is a BC-break, I believe.

@seb-jean seb-jean closed this by deleting the head repository Jan 25, 2023
fabpot added a commit that referenced this pull request 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

Development

Successfully merging this pull request may close these issues.

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

6 participants