jawira/case-converter
Composer 安装命令:
composer require 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.
关键字:
README 文档
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:
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...
jawira/case-converter 适用场景与选型建议
jawira/case-converter 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 7.61M 次下载、GitHub Stars 达 174, 最近一次更新时间为 2017 年 10 月 25 日, 在 PHP 生态内属于活跃度较高的组件。
它主要适用于以下技术方向: 「camel case」 「dot notation」 「lower case」 「kebab case」 「sentence case」 「snake case」 等业务场景。在实际项目中,围绕这些方向常见需要落地的问题包括:接口对接、性能调优、并发安全、与既有框架(Laravel / ThinkPHP / Yii / Webman 等)的兼容适配,以及生产环境的日志埋点与稳定性保障。
我们在过去多个企业项目中使用过 jawira/case-converter 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。
基于 jawira/case-converter 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。
线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。
承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。
与 jawira/case-converter 相关的其它包
同方向 / 同关键字的高下载量 PHP Composer 包推荐,方便对比选型:
Symfony2 Case Converter Bundle
Class to store and access data in a case-insensitive fashion, while maintaining the integrity and functionality of a regular array.
A converter for strings in most popular cases
OriginPHP Inflector
Access array data quickly/easily using dot-notation and asterisk.
Compatibility layer for emulating enumerations in PHP < 8.1 and native enumerations in PHP >= 8.1
统计信息
- 总下载量: 7.61M
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 182
- 点击次数: 34
- 依赖项目数: 84
- 推荐数: 4
其他信息
- 授权协议: MIT
- 更新时间: 2017-10-25