PHPackages                             talesoft/tale-inflector - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. talesoft/tale-inflector

ActiveLibrary

talesoft/tale-inflector
=======================

A library that can inflect strings to many formats

0.2.0(8y ago)21.1k[1 issues](https://github.com/Talesoft/tale-inflector/issues)1MITPHPPHP &gt;=7.1.0

Since May 20Pushed 7y ago3 watchersCompare

[ Source](https://github.com/Talesoft/tale-inflector)[ Packagist](https://packagist.org/packages/talesoft/tale-inflector)[ Docs](http://docs.talesoft.codes/php/tale/inflector)[ RSS](/packages/talesoft-tale-inflector/feed)WikiDiscussions master Synced 1mo ago

READMEChangelog (2)Dependencies (1)Versions (3)Used By (1)

[![Packagist](https://camo.githubusercontent.com/6d9e765ca41cbd63c2be19adbc14ce7daa0adb671e80cbef24c23bfb9d3e9024/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f762f74616c65736f66742f74616c652d696e666c6563746f722e7376673f7374796c653d666f722d7468652d6261646765)](https://packagist.org/packages/talesoft/tale-inflector)[![License](https://camo.githubusercontent.com/7d4c6eed9c0d55766155c9a12529fdbc97a532c54f82d9be1899b64cb0ec1123/68747470733a2f2f696d672e736869656c64732e696f2f6769746875622f6c6963656e73652f54616c65736f66742f74616c652d696e666c6563746f722e7376673f7374796c653d666f722d7468652d6261646765)](https://github.com/Talesoft/tale-inflector/blob/master/LICENSE.md)[![CI](https://camo.githubusercontent.com/c644980025abdc14235d404fdf5f208931e7fd8df00f761d4da9ac837ba417c9/68747470733a2f2f696d672e736869656c64732e696f2f7472617669732f54616c65736f66742f74616c652d696e666c6563746f722e7376673f7374796c653d666f722d7468652d6261646765)](https://travis-ci.org/Talesoft/tale-inflector)[![Coverage](https://camo.githubusercontent.com/dedec123474bb36d0541a1938d5395645bad64c20392bef5ffd23b079f8e0b1d/68747470733a2f2f696d672e736869656c64732e696f2f636f6465636c696d6174652f636f7665726167652f54616c65736f66742f74616c652d696e666c6563746f722e7376673f7374796c653d666f722d7468652d6261646765)](https://codeclimate.com/github/Talesoft/tale-inflector)

Tale Inflector
==============

[](#tale-inflector)

What is Tale Inflector?
-----------------------

[](#what-is-tale-inflector)

Tale inflector bends strings into different naming styles. A common use-case would be the converting of class-names or property-names to table-names or titles to slugs for URLs.

It can also generate the plural or singular of a string or ordinalize numbers.

Installation
------------

[](#installation)

```
composer require talesoft/tale-inflector
```

Usage
-----

[](#usage)

```
use Tale\Inflector;

$inflector = new Inflector();

//Table generation
$inflector->inflect('ProductAttribute', ['tableize', 'pluralize']); //product_attributes
$inflector->inflect('someProperty', ['tableize']); //some_property

//Canonicalization / slugs
$inflector->inflect('Some title I inserted', ['canonicalize']); //some-title-i-inserted
$inflector->inflect('Was höre ich da?', ['canonicalize']); //was-hore-ich-da

//Or just use the static methods for quick access
Inflector::canonicalize('Some random title'); //some-random-title
```

Available strategies/static methods
-----------------------------------

[](#available-strategiesstatic-methods)

### camelize

[](#camelize)

> Tale\\Inflector\\Strategy\\CamelCaseStrategy

```
some Random string = SomeRandomString

```

### dasherize

[](#dasherize)

> Tale\\Inflector\\Strategy\\DashRejoinStrategy

```
some Random string = some-Random-string

```

### canonicalize

[](#canonicalize)

> Tale\\Inflector\\Strategy\\KebabCaseStrategy

```
some Random string = some-random-string

```

### variableize

[](#variableize)

> Tale\\Inflector\\Strategy\\LowerCamelCaseStrategy

```
some Random string = someRandomString

```

### constantize

[](#constantize)

> Tale\\Inflector\\Strategy\\MacroCaseStrategy

```
some Random string = SOME_RANDOM_STRING

```

### tableize

[](#tableize)

> Tale\\Inflector\\Strategy\\SnakeCaseStrategy

```
some Random string = some_random_string

```

### underscorize

[](#underscorize)

> Tale\\Inflector\\Strategy\\UnderscoreRejoinStrategy

```
some Random string = some_Random_string

```

### humanize

[](#humanize)

> Tale\\Inflector\\Strategy\\UppercaseWordsStrategy

```
some Random string = Some Random String

```

### ordinalize

[](#ordinalize)

> Tale\\Inflector\\Strategy\\NumberOrdinalStrategy

```
1 = 1st
12 = 12th
23 = 23rd

```

### pluralize

[](#pluralize)

> Tale\\Inflector\\Strategy\\MacroCaseStrategy

```
rabbit = rabbits
car = cars
house = houses

```

### singularize

[](#singularize)

> Tale\\Inflector\\Strategy\\MacroCaseStrategy

```
rabbits = rabbit
cars = car
houses = house

```

Roll your own
-------------

[](#roll-your-own)

```
use Tale\Inflector\StrategyInterface;

class MyInflectionStrategy implements StrategyInterface
{
   public function inflect(string $string): string
   {
       return "!! {$string} !!";
   }
}

$inflector->inflect('Test', [MyInflectionStrategy::class]); //!! Test !!
```

You can register your own short names

```
use Tale\Inflector\StrategyInterface;

class MyInflectionStrategy implements StrategyInterface
{
    public function inflect(string $string): string
    {
        return "!! {$string} !!";
    }
}

$inflector->addNamedStrategy('exlamize', MyInflectionStrategy::class);
$inflector->inflect('House', ['pluralize', 'exclamize']); //!! Houses !!
```

###  Health Score

24

—

LowBetter than 32% of packages

Maintenance10

Infrequent updates — may be unmaintained

Popularity17

Limited adoption so far

Community10

Small or concentrated contributor base

Maturity49

Maturing project, gaining track record

 Bus Factor1

Top contributor holds 100% of commits — single point of failure

How is this calculated?**Maintenance (25%)** — Last commit recency, latest release date, and issue-to-star ratio. Uses a 2-year decay window.

**Popularity (30%)** — Total and monthly downloads, GitHub stars, and forks. Logarithmic scaling prevents top-heavy scores.

**Community (15%)** — Contributors, dependents, forks, watchers, and maintainers. Measures real ecosystem engagement.

**Maturity (30%)** — Project age, version count, PHP version support, and release stability.

###  Release Activity

Cadence

Every ~719 days

Total

2

Last Release

2921d ago

PHP version history (2 changes)0.1PHP &gt;=5.5.0

0.2.0PHP &gt;=7.1.0

### Community

Maintainers

![](https://www.gravatar.com/avatar/75a80e0830e63c723808d021d3a1648a2643db60f4ac2e40842da05f227f956b?d=identicon)[TorbenKoehn](/maintainers/TorbenKoehn)

---

Top Contributors

[![TorbenKoehn](https://avatars.githubusercontent.com/u/1403556?v=4)](https://github.com/TorbenKoehn "TorbenKoehn (15 commits)")

---

Tags

camelizecanonicalizeinflectorordinalphppluralsingularslugifystringpluralmanipulationinflectionsingularbending

### Embed Badge

![Health badge](/badges/talesoft-tale-inflector/health.svg)

```
[![Health](https://phpackages.com/badges/talesoft-tale-inflector/health.svg)](https://phpackages.com/packages/talesoft-tale-inflector)
```

###  Alternatives

[doctrine/inflector

PHP Doctrine Inflector is a small library that can perform string manipulations with regard to upper/lowercase and singular/plural forms of words.

11.4k855.8M711](/packages/doctrine-inflector)[danielstjules/stringy

A string manipulation library with multibyte support

2.4k26.0M191](/packages/danielstjules-stringy)[voku/stringy

A string manipulation library with multibyte support

1783.8M19](/packages/voku-stringy)[statamic/stringy

A string manipulation library with multibyte support, forked from @statamic

234.5M14](/packages/statamic-stringy)[hallindavid/manny

a package of manipulators that hopefully come in useful for those of us who always forget regex when we need it (manny is short for manipulation)

38103.3k2](/packages/hallindavid-manny)[danielstjules/sliceable-stringy

Python string slices in PHP

4751.6k1](/packages/danielstjules-sliceable-stringy)

PHPackages © 2026

[Directory](/)[Categories](/categories)[Trending](/trending)[Changelog](/changelog)[Analyze](/analyze)
