koenpunt / php-inflector
该包已被弃用且不再维护。未建议替代包。
PHP Inflector,从 Rails 移植而来
v1.0.0
2014-04-10 19:13 UTC
This package is auto-updated.
Last update: 2024-08-12 11:07:27 UTC
README
PHP Inflector 库,从 Rails 移植而来
最低要求
安装
使用 PHP Inflector 最简单的方法是使用 Composer 安装
创建或更新 composer.json
{ "require": { "koenpunt/php-inflector": "1.0.*" } }
然后运行 composer install
功能
-
基础
- singularize
- pluralize
- singularize
- camelize
- underscore
- humanize
- titleize
- tableize
- classify
- dasherize
- denamespace
- foreign_key
- ordinalize
-
国际化
- transliterate
- parameterize
用法
PHP Inflector 作为具有静态函数的类实现
Inflector::underscore("PhpInflector\Inflector"); # => php_inflector/inflector PhpInflector\Inflector::parameterize("Ærøskøbing on Water"); # => aeroskobing-on-water PhpInflector\Inflector::foreign_key("Admin\Post"); # => post_id PhpInflector\Inflector::denamespace("PhpInflector\Inflector\Inflections"); # => Inflections PhpInflector\Inflector::dasherize("puni_puni"); # => puni-puni
也可以添加自定义屈折,如缩写词
PhpInflector\Inflector::inflections(function($inflect){ $inflect->acronym('RESTful'); }); PhpInflector\Inflector::titleize('RESTfulController'); # => RESTful Controller
更多示例和文档可以在源代码中找到。
贡献
- 分叉它
- 创建您的功能分支(
git checkout -b my-new-feature
) - 提交您的更改(
git commit -am 'Added some feature'
) - 推送到分支(
git push origin my-new-feature
) - 创建新的 Pull Request