https://github.com/eufony/inflector
Common interfaces for inflection libraries.
https://github.com/eufony/inflector
eufony inflection inflector php
Last synced: 3 months ago
JSON representation
Common interfaces for inflection libraries.
- Host: GitHub
- URL: https://github.com/eufony/inflector
- Owner: eufony
- License: lgpl-3.0
- Created: 2021-11-28T12:09:00.000Z (over 4 years ago)
- Default Branch: v2.x
- Last Pushed: 2023-02-08T07:54:43.000Z (over 3 years ago)
- Last Synced: 2025-05-20T22:37:25.019Z (about 1 year ago)
- Topics: eufony, inflection, inflector, php
- Language: PHP
- Homepage:
- Size: 37.1 KB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: COPYING
Awesome Lists containing this project
README
The Eufony Inflector Package
*eufony/inflector provides a standardized interface for linguistic inflection libraries.*
*eufony/inflector* is a PHP library that aims to improve interoperability between linguistic inflection implementations.
It provides a common interface for changing the capitalization of strings, as well as the pluralization and
singularization of words.
Interested? [Here's how to get started.](#getting-started)
## Getting started
### Installation
*eufony/inflector* is released as a [Packagist](https://packagist.org/) package and can be easily installed
via [Composer](https://getcomposer.org/) with:
composer require "eufony/inflector"
### Basic Usage
*eufony/inflector* provides `InflectorInterface`, which defines the following methods:
```php
// 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);
```
It also provides a couple of pseudo-implementations to get you started:
```php
// 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();
```
## Contributing
Found a bug or a missing feature? You can report it over at
the [issue tracker](https://github.com/eufony/inflector/issues).
## License
This program is free software: you can redistribute it and/or modify it under the terms of the GNU Lesser General Public
License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later
version.
This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied
warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more
details.
You should have received a copy of the GNU Lesser General Public License along with this program. If not,
see .