eufony/屈折

屈折库的常见接口。

v2.1.1 2023-02-08 07:54 UTC

This package is auto-updated.

Last update: 2024-09-08 10:59:49 UTC


README

Packagist Downloads GitHub Stars Issues
License Community Built

eufony/inflector 提供了语言屈折库的标准化接口。

eufony/inflector 是一个 PHP 库,旨在提高语言屈折实现之间的互操作性。它提供了一个公共接口,用于更改字符串的大小写,以及单词的单复数形式。

感兴趣? 这里是如何开始的。

开始使用

安装

eufony/inflectorPackagist 包的形式发布,可以通过 Composer 简单安装。

composer require "eufony/inflector"

基本用法

eufony/inflector 提供 InflectorInterface,该接口定义了以下方法

// Convert between `PascalCase`, `snake_case`, and `camelCase`.
echo $inflector->toPascalCase($string);
echo $inflector->toSnakeCase($string);
echo $inflector->toCamelCase($string);

// Convert between pluralized and singularized words.
echo $inflector->pluralize($string);
echo $inflector->singularize($string);

它还提供了一些伪实现,以帮助您开始

// A fake implementation based on the Null Object Pattern
// that returns any string it is given without any modifications.
$inflector = new NullInflector();

// A wrapper class to manually define exceptions to the return values of another implementation.
$inflector = new ExceptionAdapter($inflector, cases: [["id", "id", "ID"]], words: ["moose", "meese"]);

// A wrapper class around the inflector implementation by the Doctrine project.
$inflector = new DoctrineInflector();

贡献

发现了一个错误或缺失的功能?您可以在 问题跟踪器 上报告。

许可协议

本程序是自由软件:您可以在自由软件基金会发布的 GNU 宽通用公共许可证的条款下重新分发和/或修改它,许可证版本为 3 或(按您的选择)任何更高版本。

本程序以希望对您有用的方式分发,但没有任何保证;甚至没有关于其适销性或适用于特定用途的暗示性保证。有关详细信息,请参阅 GNU 宽通用公共许可证。

您应该已经随本程序收到了一份 GNU 宽通用公共许可证的副本。如果没有,请参阅 https://gnu.ac.cn/licenses/