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.
Installs: 4 468 171
Dependents: 81
Suggesters: 3
Security: 0
Stars: 167
Watchers: 5
Forks: 8
Open Issues: 3
Requires
- php: >=7.4
- ext-mbstring: *
Requires (Dev)
- behat/behat: ^3.0
- phpstan/phpstan: ^1.0
- phpunit/phpunit: ^9.0
- vimeo/psalm: ^4.0
Suggests
- pds/skeleton: PHP Package Development Standards
- phing/phing: PHP Build Tool
This package is auto-updated.
Last update: 2024-11-13 23:18:56 UTC
README
Use this library to convert string between:
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
License
This library is licensed under the MIT LICENSE.
Packages from jawira
- 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...