allansun / camel
一个处理单词大小写转换的迷你库。最初来源于 https://github.com/MattKetmo/camel
v1.1.0
2015-05-13 13:51 UTC
Requires (Dev)
- phpunit/phpunit: 4.6.*
This package is auto-updated.
Last update: 2024-08-26 20:59:09 UTC
README
一个处理单词大小写转换的迷你库。
主要思路是将给定的单词分割成几个单词,并以另一种格式重新组装。
示例:camelCase => [camel, Case] => camel_case
安装
composer require mattketmo/camel
使用方法
<?php require __DIR__.'/vendor/autoload.php'; use Camel\CaseTransformer; use Camel\Format; $transformer1 = new CaseTransformer(new Format\SnakeCase, new Format\CamelCase); $transformer2 = new CaseTransformer(new Format\CamelCase, new Format\ScreamingSnakeCase); echo $transformer1->transform('hello_world'); // helloWorld echo $transformer2->transform('helloWorld'); // HELLO_WORLD
支持的格式
camelCase
StudlyCaps
snake_case
SCREAMING_SNAKE_CASE
spinal-case
单元测试
通过Composer安装 phpunit
composer install
安装完成后,运行以下命令
vendor/bin/phpunit
许可证
Camel遵循MIT许可证发布。有关详细信息,请参阅包含的LICENSE文件。