Description
Convert strings between 13 naming conventions: Snake case, Camel case, Kebab case, Pascal case, Ada case, Train case, Cobol case, Macro case, Upper case, Lower case, Title case, Sentence case and Dot notation.
Case converter alternatives and similar libraries
Based on the "Strings" category.
Alternatively, view Case converter alternatives based on common mentions on social networks and blogs.
-
Google Translate For Free
google-translator translation language-detection detect-language translate php google-translate translator -
Russian metaphone phonetic algorithm implementation for PHP
Russian metaphone algorithm implementation
Get performance insights in less than 4 minutes
* Code Quality Rankings and insights are calculated and provided by Lumnify.
They vary from L1 to L5 with "L5" being the highest. Visit our partner's website for more details.
Do you think we are missing an alternative of Case converter or a related project?
README
Case converter
Use this library to convert string between:
Name | Method | Output example |
---|---|---|
🐪 Camel case | toCamel() |
myNameIsBond |
👨🏫 Pascal case | toPascal() |
MyNameIsBond |
🐍 Snake case | toSnake() |
my_name_is_bond |
👩🏫 Ada case | toAda() |
My_Name_Is_Bond |
Ⓜ️ Macro case | toMacro() |
MY_NAME_IS_BOND |
🥙 Kebab case | toKebab() |
my-name-is-bond |
🚂 Train case | toTrain() |
My-Name-Is-Bond |
🏦 Cobol case | toCobol() |
MY-NAME-IS-BOND |
🔡 Lower case | toLower() |
my name is bond |
🔠 Upper case | toUpper() |
MY NAME IS BOND |
📰 Title case | toTitle() |
My Name Is Bond |
✍️ Sentence case | toSentence() |
My name is bond |
⚙️ Dot notation | toDot() |
my.name.is.bond |
Features:
Usage
Input string (i.e. john-connor) format is going to be detected automatically. Here's an example:
use Jawira\CaseConverter\Convert;
$hero = new Convert('john-connor');
echo $hero->toCamel(); // output: johnConnor
Of course you can explicitly set the format of input string:
echo $hero->fromKebab()->toSnake(); // output: john_connor
You can also use the provided factory to instantiate Convert
class.
A list of all public methods is also available.
i18n
Fully compatible with non-english alphabets:
// Spanish
$esp = new Convert('DON_RAMÓN_Y_ÑOÑO');
echo $esp->toCamel(); // output: donRamónYÑoño
// Greek
$grc = new Convert('πολύ-Καλό');
echo $grc->toCamel(); // output: πολύΚαλό
// Russian
$rus = new Convert('ОЧЕНЬ_ПРИЯТНО');
echo $rus->toCamel(); // output: оченьПриятно
case-converter
is compatible with Simple Case-Mapping and Full
Case-Mapping. Learn more about Case-Mapping.
Installation
$ composer require jawira/case-converter
Documentation
https://jawira.github.io/case-converter/
Contributing
- If you liked this project, ⭐ star it on GitHub.
- Pull requests and issues are welcomed.
Contributors
License
This library is licensed under the MIT LICENSE.
<!--mkdocs: Do not use relative path for links and images-->
Packages from jawira
jawira/emoji-catalog (library) Get access to +3000 emojis as class constants.
jawira/phing-visualizer (library) Graphical representation of Phing's buildfile.
jawira/phing-open-task (library) Phing task to open files, directories, and URLs with your favorite software.
more...
*Note that all licence references and agreements mentioned in the Case converter README section above
are relevant to that project's source code only.