jawira/case-converter
Convert strings between 13 naming conventions: Snake case, Camel case, Pascal case, Kebab case, Ada case, Train case, Cobol case, Macro case, Upper case, Lower case, Sentence case, Title case and Dot notation.
Maintainers
Requires
- php: >=7.4
- ext-mbstring: *
Requires (Dev)
- behat/behat: ^3.0
- phpstan/phpstan: ^v2
- phpunit/phpunit: ^9.0
Suggests
- pds/skeleton: PHP Package Development Standards
- phing/phing: PHP Build Tool
Provides
None
Conflicts
None
Replaces
None
MIT de9956122568743a83e0fc7e2eaa92c1b0de3f18
- Jawira Portugal <dev.woop@tugal.be>
camel casedot notationlower casekebab casesentence casesnake casetitle caseupper casepascal caseAda caseTrain caseCobol caseMacro case
This package is auto-updated.
Last update: 2026-06-13 23:53:58 UTC
README
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:
- π automatic case detection
- π factory
- π i18n
π Packagist Version
π Packagist PHP Version Support
π Packagist Downloads
π Packagist License
π Maintainability
π Test Coverage
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.
π GitHub Repo stars
- Or follow me on X.
π Twitter Follow
License
This library is licensed under the MIT LICENSE.
Packages from jawira
-
jawira/emoji-catalog
π GitHub stars
- Get access to +3000 emojis as class constants.
-
jawira/plantuml-client
π GitHub stars
- Convert PlantUML diagrams into images (svg, png, ...).
-
jawira/doctrine-diagram-bundle
π GitHub stars
- Symfony Bundle to generate database diagrams.
- more...
