项目作者: jawira

项目描述 :
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.
高级语言: PHP
项目地址: git://github.com/jawira/case-converter.git
创建时间: 2015-09-07T20:41:06Z
项目社区:https://github.com/jawira/case-converter

开源协议:MIT License

下载


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:

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:

  1. use Jawira\CaseConverter\Convert;
  2. $hero = new Convert('john-connor');
  3. echo $hero->toCamel(); // output: johnConnor

Of course you can explicitly set the format of input string:

  1. 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:

  1. // Spanish
  2. $esp = new Convert('DON_RAMÓN_Y_ÑOÑO');
  3. echo $esp->toCamel(); // output: donRamónYÑoño
  4. // Greek
  5. $grc = new Convert('πολύ-Καλό');
  6. echo $grc->toCamel(); // output: πολύΚαλό
  7. // Russian
  8. $rus = new Convert('ОЧЕНЬ_ПРИЯТНО');
  9. echo $rus->toCamel(); // output: оченьПриятно

case-converter is compatible with Simple Case-Mapping and Full
Case-Mapping
.
Learn more about Case-Mapping.

Installation

  1. 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…