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

[10.x] Create fluent method convertCase #48492

Merged
merged 12 commits into from
Sep 21, 2023
Merged

Conversation

rmunate
Copy link
Contributor

@rmunate rmunate commented Sep 21, 2023

In a previous PR the Str::convertCase method was accepted and combined but I did not create the fluent method via Str::of(), the goal of this request is to add this method, I will be following the review of this request, later I will create the change request to the documentation, where I see that now the Strings will have their unique page. Thank you.

rmunate and others added 11 commits August 28, 2023 18:11
This function, convertCase, serves the purpose of converting the case of a given string while taking into account multibyte characters and character encoding. It offers flexibility by allowing you to specify the conversion mode and character encoding, with sensible defaults provided for ease of use.

Here's a breakdown of its functionality:

String: You provide a string as the input, which is the text you want to change the case of.

Conversion Mode (Optional): The function allows you to specify the conversion mode through the $mode parameter. By default, it uses MB_CASE_FOLD, which converts the string to lowercase. However, you can change this mode according to your requirements.

Character Encoding (Optional): You can also specify the character encoding through the $encoding parameter. The default encoding is 'UTF-8,' but you can set it to a different encoding if needed. If no encoding is provided, it will use the internal encoding.

Output: The function returns the converted string with the specified case and encoding.
@taylorotwell
Copy link
Member

This doesn't look correct. It should return a new Stringable like the other methods (see trim, etc.).

@rmunate
Copy link
Contributor Author

rmunate commented Sep 21, 2023

@taylorotwell Sorry for the situation, I omitted to return a new static instance.

@taylorotwell taylorotwell merged commit 19357ef into laravel:10.x Sep 21, 2023
20 checks passed
timacdonald pushed a commit to timacdonald/framework that referenced this pull request Sep 22, 2023
* Add method `Str::convertCase`

This function, convertCase, serves the purpose of converting the case of a given string while taking into account multibyte characters and character encoding. It offers flexibility by allowing you to specify the conversion mode and character encoding, with sensible defaults provided for ease of use.

Here's a breakdown of its functionality:

String: You provide a string as the input, which is the text you want to change the case of.

Conversion Mode (Optional): The function allows you to specify the conversion mode through the $mode parameter. By default, it uses MB_CASE_FOLD, which converts the string to lowercase. However, you can change this mode according to your requirements.

Character Encoding (Optional): You can also specify the character encoding through the $encoding parameter. The default encoding is 'UTF-8,' but you can set it to a different encoding if needed. If no encoding is provided, it will use the internal encoding.

Output: The function returns the converted string with the specified case and encoding.

* Adjust StyleCI

* formatting

* [10.x] Create fluent method convertCase

* [10.x] Return New Stringable

---------

Co-authored-by: Taylor Otwell <taylor@laravel.com>
Co-authored-by: rmunate <raulunatecastro@MacBook-Pro-de-Raul.local>
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.

None yet

2 participants