An open API service indexing awesome lists of open source software.

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.

Awesome Lists containing this project

README

          

The Eufony Inflector Package



Packagist Downloads


GitHub Stars


Issues




License


Community Built

*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 .