定制 mmucklo/inflect 二次开发

按需修改功能、优化性能、对接业务系统,提供一站式技术支持

邮箱:yvsm@zunyunkeji.com | QQ:316430983 | 微信:yvsm316

mmucklo/inflect

Composer 安装命令:

composer require mmucklo/inflect

包简介

inflect - a memoizing inflector for php

README 文档

README

CI codecov Scrutinizer Code Quality Latest Stable Version License

Inflect is a memoizing inflector for PHP — pluralize, singularize, and format counted nouns for English.

Requirements

  • PHP 8.1+ (the legacy PHP 5.3 baseline is maintained on the php5.3 branch for back-ports)

Installation

composer require mmucklo/inflect

Usage

use Inflect\Inflect;

Inflect::pluralize('test');        // 'tests'
Inflect::singularize('tests');     // 'test'
Inflect::pluralizeIf(1, 'cat');    // '1 cat'
Inflect::pluralizeIf(3, 'person'); // '3 people'

Irregulars, uncountables, and case are handled automatically:

Inflect::pluralize('Man');         // 'Men'
Inflect::pluralize('datum');       // 'data'
Inflect::pluralize('news');        // 'news'
Inflect::singularize('criteria');  // 'criterion'
Inflect::singularize('Children');  // 'Child'

// Double-inflection is a no-op:
Inflect::pluralize('people');      // 'people'
Inflect::singularize('datum');     // 'datum'

Results are memoized in a process-local static cache.

API

Inflect::pluralize(string $string): string

Returns the plural form of the given word. Empty input returns ''.

Inflect::singularize(string $string): string

Returns the singular form of the given word. Empty input returns ''.

Inflect::pluralizeIf(int $count, string $string): string

Returns "$count $word" with the word pluralized when $count !== 1.

Passing null to any of these methods raises a TypeError — callers should handle null explicitly.

Versioning

Semantic versioning. The currently supported line is 2.x (PHP 8.1+).

See CHANGELOG.md for release history and ROADMAP.md for planned work (locale support, extension APIs, etc.).

Upgrading from 1.x

2.0.0 is a breaking release. Highlights:

  • PHP 8.1+ required (was 5.3.17+).
  • src/Inflect/Inflect.php moved to src/Inflect.php (PSR-0 → PSR-4).
  • Inflect is final; rule tables are private.
  • pluralize(null) / singularize(null) now throw TypeError.
  • phpunit.xml-dist renamed to phpunit.xml.dist (PHPUnit 10 convention).

Full list in the v2.0.0 release notes.

Contributing

See CONTRIBUTING.md for dev setup, running the test / static analysis / style suite, and PR conventions.

Credits

Originally forked from Sho Kuwamoto's improved pluralizer. Many thanks to Sho, and to the Ruby on Rails and Doctrine inflector projects from which rule patterns continue to be borrowed.

License

MIT — see LICENSE.

mmucklo/inflect 适用场景与选型建议

mmucklo/inflect 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 24.35M 次下载、GitHub Stars 达 40, 最近一次更新时间为 2015 年 05 月 16 日, 在 PHP 生态内属于活跃度较高的组件。

它主要适用于以下技术方向: 「inflect」 「urlify」 「inflector」 「singularize」 「pluralize」 等业务场景。在实际项目中,围绕这些方向常见需要落地的问题包括:接口对接、性能调优、并发安全、与既有框架(Laravel / ThinkPHP / Yii / Webman 等)的兼容适配,以及生产环境的日志埋点与稳定性保障。

我们在过去多个企业项目中使用过 mmucklo/inflect 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。

围绕 mmucklo/inflect 我们能提供哪些服务?
定制开发 / 二次开发

基于 mmucklo/inflect 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。

BUG 修复 & 性能优化

线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。

项目外包 & 长期维护

承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。

yvsm@zunyunkeji.com QQ:316430983 微信:yvsm316 西安尊云信息科技 · 专注 PHP / Go / 分布式系统研发

统计信息

  • 总下载量: 24.35M
  • 月度下载量: 0
  • 日度下载量: 0
  • 收藏数: 41
  • 点击次数: 29
  • 依赖项目数: 19
  • 推荐数: 0

GitHub 信息

  • Stars: 40
  • Watchers: 3
  • Forks: 7
  • 开发语言: PHP

其他信息

  • 授权协议: MIT
  • 更新时间: 2015-05-16