rhdevelopment/inflecta

Inflecta: lightweight string inflector utilities for modern PHP projects.

Maintainers

Package info

github.com/hadley8899/string-inflector

pkg:composer/rhdevelopment/inflecta

Statistics

Installs: 0

Dependents: 0

Suggesters: 0

Stars: 0

Open Issues: 0

v0.1.0 2025-10-24 10:53 UTC

This package is auto-updated.

Last update: 2026-02-28 16:14:45 UTC


README

Inflecta is a lightweight PHP 8.2+ string inflector that helps you convert between camelCase, snake_case, kebab-case, and title case while handling simple pluralization, singularization, and slug generation. It is perfect for REST APIs, CLI tooling, and framework-agnostic utilities that need consistent naming conventions.

Why Inflecta?

  • Zero dependencies and PSR-4 autoload ready.
  • Accurate delimiter normalization across spaces, underscores, and hyphens.
  • Case conversion helpers for camel, pascal, snake, constant, kebab, and title casing.
  • Simple pluralization and singularization rules for common English words.
  • Table/class naming helpers (classify, tableize) plus human-readable transformations and SEO-friendly slug creation.

Installation

composer require ryan/inflecta

Inflecta targets PHP 8.2 or newer. The package ships with a PHPUnit test suite for easy integration into continuous integration pipelines.

Quick Start

<?php

use Ryan\Inflecta\Inflecta;

Inflecta::toCamelCase('user_profile');          // userProfile
Inflecta::toPascalCase('user profile');         // UserProfile
Inflecta::toSnakeCase('HTTPResponseCode');      // http_response_code
Inflecta::toKebabCase('makeItSo');              // make-it-so
Inflecta::toTitleCase('customer_id');           // Customer Id
Inflecta::toConstantCase('statusFlag');         // STATUS_FLAG

Inflecta::pluralize('category');                // categories
Inflecta::singularize('boxes');                 // box
Inflecta::humanize('apiClient');                // Api client
Inflecta::slugify('Hello, World!');             // hello-world
Inflecta::classify('order_items');              // OrderItem
Inflecta::tableize('OrderItem');                // order_items

For a complete walkthrough, check the bundled example script:

php examples/demo.php

Testing

Inflecta includes PHPUnit tests covering every helper:

composer install
composer test

Contributing

Issues and pull requests are welcome on GitHub. Feel free to open a ticket if you spot an edge case or have ideas for new inflection rules.

License

MIT License © Ryan / RH Development.