PHPackages                             borisguery/inflexible - 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. borisguery/inflexible

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

borisguery/inflexible
=====================

Collection of Inflectors for string, date, numbers, etc.

191.8k3[4 issues](https://github.com/borisguery/Inflexible/issues)PHP

Since Jun 17Pushed 12y ago2 watchersCompare

[ Source](https://github.com/borisguery/Inflexible)[ Packagist](https://packagist.org/packages/borisguery/inflexible)[ RSS](/packages/borisguery-inflexible/feed)WikiDiscussions master Synced 1mo ago

READMEChangelogDependenciesVersions (1)Used By (0)

Inflexible [![Build Status](https://camo.githubusercontent.com/e454dde434a3d89168dab05f1d68c3507fe4d6522ae04a770371b65be5ff8417/68747470733a2f2f7472617669732d63692e6f72672f626f72697367756572792f496e666c657869626c652e706e673f6272616e63683d6d6173746572)](https://travis-ci.org/borisguery/Inflexible)
=========================================================================================================================================================================================================================================================================================================

[](#inflexible--)

Table of contents
-----------------

[](#table-of-contents)

1. [Description](#description)
2. [Installation](#installation)
3. [Usage](#usage)
4. [Available inflectors](#available-inflectors)
5. [Datetime](#datetime)1. [Relative](#relative)
6. [Number](#number)1. [HumanByte](#humanbyte)2. [Ordinalize](#ordinalize)3. [Shorten](#shorten)4. [Textualize](#textualize)
7. [String](#string)1. [Camelize](#camelize)2. [Denamespace](#denamespace)3. [Humanize](#humanize)4. [NamespaceOnly](#namespaceonly)5. [Slugify](#slugify)
8. [Run the test](#run-the-test)
9. [Contributing](#contributing)
10. [Requirements](#requirements)
11. [Authors](#authors)
12. [License](#license)

Description
-----------

[](#description)

Inflexible aims to gather a collection of commonly used Inflectors into a single lib.

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

[](#installation)

Using [Composer](http://getcomposer.org/), just `$ composer require borisguery/inflexible` package or:

```
{
  "require": {
    "borisguery/inflexible": "dev-master"
  }
}
```

Usage
-----

[](#usage)

### Available inflectors

[](#available-inflectors)

#### Datetime

[](#datetime)

##### Relative

[](#relative)

Convert a `DateTime` object or a number of seconds into the most fitted unit:

```
Inflexible::relativeDatetime(86400);
```

Returns

```
array(
    1,
    'day'
)
```

You may also want to get the relative datetime from a given date:

```
Inflexible::relativeDatetime(new DateTime('2012-01-10'), new DateTime('2012-01-17'));
```

Returns

```
array(
    1,
    'week'
)
```

The available units are:

- second
- minute
- hour
- day
- week
- month
- year

#### Number

[](#number)

##### HumanByte

[](#humanbyte)

Convert bytes to an human readable representation to the most fitted unit:

```
Inflexible::humanByte(1024);
// 1.00 KB
```

```
Inflexible::humanByte(1048576);
// 1.00 MB
```

```
Inflexible::humanByte(1073741824);
// 1.00 GB
```

You may also provided an optional precision as a second argument (default to 2)

##### Ordinalize

[](#ordinalize)

Converts number to its ordinal English form:

```
Inflexible::ordinalize(1);
// 1st
```

```
Inflexible::ordinalize(13);
// 13th
```

##### Shorten

[](#shorten)

Formats a number using the SI units (k, M, G, etc.):

```
Inflexible::shorten(100);
// array(100, null)
// No units for number < 1000
```

```
Inflexible::shorten(1523);
// 1k
```

##### Textualize

[](#textualize)

Returns the textual representation of a number

```
Inflexible::textualize(1025433);
// One Million, Twenty Five Thousand, Four Hundred and Thirty Three
```

#### String

[](#string)

##### Camelize

[](#camelize)

Converts a word like "foo\_bar" to "FooBar". It also removes non-alphanumeric characters:

```
Inflexible::camelize('foo_bar');
// FooBar
```

##### Denamespace

[](#denamespace)

Returns only the class name

```
Inflexible::denamespace('\Foo\Bar\Baz');
// Baz
```

##### Humanize

[](#humanize)

Converts CamelCased word and underscore to space to return a readable string:

```
Inflexible::humanize('foo_bar');
// Foo Bar
```

```
Inflexible::humanize('FooBar');
// Foo Bar
```

##### NamespaceOnly

[](#namespaceonly)

Returns the namespace of a fully qualified class name:

```
Inflexible::namespaceOnly('\Foo\Bar\Baz');
// Foo\Bar
```

##### Slugify

[](#slugify)

Slugify a string:

```
Inflexible::namespaceOnly('lo\rem ipsum do|or sid amet||| #\`[|\" 10 .');
// lo-rem-ipsum-do-or-sid-amet-10
```

You may optionally set the separator, a max length or decide to whether lower the case:

```
Inflexible::slugify(
    'LoRem ipsum do|or sid amet||| #\`[|\" 10 .',
    array(
        'maxlength' => 4,
        'lowercase' => true,
        'separator' => '_'
    )
);
// lore
```

Run the test
------------

[](#run-the-test)

First make sure you have installed all the dependencies, run:

`$ composer install --dev`

then, run the test from within the root directory:

`$ phpunit`

Contributing
------------

[](#contributing)

1. Take a look at the [list of issues](http://github.com/borisguery/gisele/issues).
2. Fork
3. Write a test (for either new feature or bug)
4. Make a PR

Requirements
------------

[](#requirements)

- PHP 5.3+

Authors
-------

[](#authors)

Boris Guéry -  -  -

License
-------

[](#license)

`Inflexible` is licensed under the WTFPL License - see the LICENSE file for details

###  Health Score

25

—

LowBetter than 37% of packages

Maintenance16

Infrequent updates — may be unmaintained

Popularity25

Limited adoption so far

Community10

Small or concentrated contributor base

Maturity41

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.

### Community

Maintainers

![](https://www.gravatar.com/avatar/e697c30c60bfd1c329e9661645ba5a79dd62d6375e48656b9ba9eaf54fd59956?d=identicon)[borisguery](/maintainers/borisguery)

---

Top Contributors

[![borisguery](https://avatars.githubusercontent.com/u/345495?v=4)](https://github.com/borisguery "borisguery (41 commits)")

### Embed Badge

![Health badge](/badges/borisguery-inflexible/health.svg)

```
[![Health](https://phpackages.com/badges/borisguery-inflexible/health.svg)](https://phpackages.com/packages/borisguery-inflexible)
```

###  Alternatives

[ircmaxell/php-math-parser

A simple shunting-yard based math parser and executor for PHP

2916.7k](/packages/ircmaxell-php-math-parser)[bmcclure/cakephp-media-plugin

CakePHP Media Plugin

591.4k](/packages/bmcclure-cakephp-media-plugin)

PHPackages © 2026

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