[10.x] Add method Str::convertCase
#48224
Merged
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
According to PR #48221 the already existing methods are not touched.