PHPackages                             didanurwanda/inflector-php - 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. [Utility &amp; Helpers](/categories/utility)
4. /
5. didanurwanda/inflector-php

ActiveLibrary[Utility &amp; Helpers](/categories/utility)

didanurwanda/inflector-php
==========================

A lightweight PHP utility for smart word transformations – from singular to plural, snake\_case to camelCase, and everything in between. Fully compatible with PHP 7.1 through 8.4.

v1.0.2(9mo ago)00MITPHPPHP &gt;=7.1CI passing

Since Sep 18Pushed 9mo agoCompare

[ Source](https://github.com/didanurwanda/inflector-php)[ Packagist](https://packagist.org/packages/didanurwanda/inflector-php)[ Docs](https://github.com/didanurwanda/inflector-php)[ RSS](/packages/didanurwanda-inflector-php/feed)WikiDiscussions master Synced today

READMEChangelog (3)Dependencies (1)Versions (4)Used By (0)

Inflector PHP
=============

[](#inflector-php)

A lightweight PHP utility for smart word transformations – from singular to plural, snake\_case to CamelCase, and everything in between. Fully compatible with PHP 7.1 through 8.4.

> **Note:**
> This library is a PHP port of the popular JavaScript library [inflector-js](https://www.npmjs.com/package/inflector-js), bringing similar functionality for smart word transformations such as singular/plural conversion and case formatting.

---

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

[](#installation)

Install via Composer:

```
composer require didanurwanda/inflector-php
```

Or include manually:

```
require_once 'src/Inflector.php';
```

---

How to Use
----------

[](#how-to-use)

```
use Inflector\Inflector;

echo Inflector::camelize('message_properties');
```

---

API
---

[](#api)

### pluralize

[](#pluralize)

public static function pluralize(string $str, string $plural = null): string

Returns the plural form of a string.

Example:

```
Inflector::pluralize('person'); // people
Inflector::pluralize('Hat'); // Hats
Inflector::pluralize('person', 'persons'); // persons
Inflector::pluralize('person', 'guys'); // guys
```

---

### singularize

[](#singularize)

public static function singularize(string $str, string $singular = null): string

Example:

```
Inflector::singularize('people'); // person
Inflector::singularize('octopi'); // octopus
Inflector::singularize('hats'); // hat
Inflector::singularize('guys', 'person'); // person
```

---

### camelize

[](#camelize)

public static function camelize(string $str, bool $lowFirstLetter = false): string

Example:

```
Inflector::camelize('message_properties'); // MessageProperties
Inflector::camelize('message_properties', true); // messageProperties
```

---

### underscore

[](#underscore)

public static function underscore(string $str): string

Example:

```
Inflector::underscore('MessageProperties'); // message_properties
Inflector::underscore('messageProperties'); // message_properties
```

---

### humanize

[](#humanize)

public static function humanize(string $str, bool $lowFirstLetter = false): string

Example:

```
Inflector::humanize('message_properties'); // Message properties
Inflector::humanize('messageProperties', true); // message properties
```

---

### capitalize

[](#capitalize)

public static function capitalize(string $str): string

Example:

```
Inflector::capitalize('message properties'); // Message properties
Inflector::capitalize('message_properties'); // Message_properties
```

---

### dasherize

[](#dasherize)

public static function dasherize(string $str): string

Example:

```
Inflector::dasherize('message properties'); // message-properties
Inflector::dasherize('message_properties'); // message-properties
```

---

### camel2words

[](#camel2words)

public static function camel2words(string $str, bool $allFirstUpper = false): string

Example:

```
Inflector::camel2words('message_properties'); // Message Properties
Inflector::camel2words('message properties'); // Message Properties
Inflector::camel2words('Message_propertyId', true); // Message Property Id
```

---

### demodulize

[](#demodulize)

public static function demodulize(string $str): string

Example:

```
Inflector::demodulize('Message::Bus::Properties'); // Properties
```

---

### tableize

[](#tableize)

public static function tableize(string $str): string

Example:

```
Inflector::tableize('MessageBusProperty'); // message_bus_properties
```

---

### classify

[](#classify)

public static function classify(string $str): string

Example:

```
Inflector::classify('message_bus_properties'); // MessageBusProperty
```

---

### foreignKey

[](#foreignkey)

public static function foreignKey(string $str, bool $dropIdUbar = false): string

Example:

```
Inflector::foreignKey('MessageBusProperty'); // message_bus_property_id
Inflector::foreignKey('MessageBusProperty', true); // message_bus_propertyid
```

---

### ordinalize

[](#ordinalize)

public static function ordinalize(string $str): string

Example:

```
Inflector::ordinalize('the 1 pitch'); // the 1st pitch
Inflector::ordinalize('1'); // 1st
Inflector::ordinalize('2'); // 2nd
Inflector::ordinalize('3'); // 3rd
Inflector::ordinalize('4'); // 4th
```

---

Author
------

[](#author)

Created and maintained by **Dida Nurwanda**

---

License
-------

[](#license)

This project is licensed under the **MIT**. See the [LICENSE](./LICENSE) file for more details.

###  Health Score

25

—

LowBetter than 35% of packages

Maintenance56

Moderate activity, may be stable

Popularity0

Limited adoption so far

Community6

Small or concentrated contributor base

Maturity33

Early-stage or recently created project

 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 ~0 days

Total

3

Last Release

288d ago

### Community

Maintainers

![](https://avatars.githubusercontent.com/u/2518113?v=4)[Dida Nurwanda](/maintainers/didanurwanda)[@didanurwanda](https://github.com/didanurwanda)

---

Top Contributors

[![didanurwanda](https://avatars.githubusercontent.com/u/2518113?v=4)](https://github.com/didanurwanda "didanurwanda (9 commits)")

---

Tags

pluralinflectorsingularstring manipulationcamelcasesnakecaseword transformation

###  Code Quality

TestsPHPUnit

### Embed Badge

![Health badge](/badges/didanurwanda-inflector-php/health.svg)

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

###  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.3k900.4M875](/packages/doctrine-inflector)[opis/string

Multibyte strings as objects

7626.6M9](/packages/opis-string)[mmucklo/inflect

inflect - a memoizing inflector for php

4024.5M14](/packages/mmucklo-inflect)[mattketmo/camel

Tiny library to handle words case transformation

29379.4k17](/packages/mattketmo-camel)[andreas-glaser/php-helpers

A comprehensive collection of PHP utility functions for array manipulation, string operations, date handling, HTML generation, form building, validation, and more. Modern PHP 8.2+ library with full type safety.

1388.1k2](/packages/andreas-glaser-php-helpers)

PHPackages © 2026

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