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 |
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:
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.
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.
composer require jawira/case-converter
https://jawira.github.io/case-converter/
This library is licensed under the MIT LICENSE.
- jawira/emoji-catalog
- Get access to +3000 emojis as class constants.
- jawira/plantuml-client
- Convert PlantUML diagrams into images (svg, png, ...).
- jawira/doctrine-diagram-bundle
- Symfony Bundle to generate database diagrams.
- more...