PHPackages                             decodelabs/dictum - 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. decodelabs/dictum

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

decodelabs/dictum
=================

Text formatting tools

v0.7.4(9mo ago)230.7k↑62.5%15MITPHPPHP ^8.4CI passing

Since Apr 13Pushed 1mo ago2 watchersCompare

[ Source](https://github.com/decodelabs/dictum)[ Packagist](https://packagist.org/packages/decodelabs/dictum)[ RSS](/packages/decodelabs-dictum/feed)WikiDiscussions develop Synced today

READMEChangelog (10)Dependencies (9)Versions (42)Used By (5)

Dictum
======

[](#dictum)

[![PHP from Packagist](https://camo.githubusercontent.com/3a1c72dbd99091ea9adf3729e5e88fe38fee2a41c272bb5f542b43c3b64610fa/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f7068702d762f6465636f64656c6162732f64696374756d3f7374796c653d666c6174)](https://packagist.org/packages/decodelabs/dictum)[![Latest Version](https://camo.githubusercontent.com/144ecf656733a542ae3400a3169877d84a529ed8c6031cbd7033117702b8172f/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f762f6465636f64656c6162732f64696374756d2e7376673f7374796c653d666c6174)](https://packagist.org/packages/decodelabs/dictum)[![Total Downloads](https://camo.githubusercontent.com/c7e91b066387bed30ee52ce72a070bd24897909c438bd835b457926f7c184e89/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f64742f6465636f64656c6162732f64696374756d2e7376673f7374796c653d666c6174)](https://packagist.org/packages/decodelabs/dictum)[![GitHub Workflow Status](https://camo.githubusercontent.com/a96bd7d938fb8166c1f14069d0b76a58ee1d3dfafb58da4e009759d515ff1457/68747470733a2f2f696d672e736869656c64732e696f2f6769746875622f616374696f6e732f776f726b666c6f772f7374617475732f6465636f64656c6162732f64696374756d2f696e746567726174652e796d6c3f6272616e63683d646576656c6f70)](https://github.com/decodelabs/dictum/actions/workflows/integrate.yml)[![PHPStan](https://camo.githubusercontent.com/e25c14ce011edabdd0fbd2e10415b41cc5d66ed11ef3e5b7edd074c5bdd35a2d/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f5048505374616e2d656e61626c65642d3434434331312e7376673f6c6f6e6743616368653d74727565267374796c653d666c6174)](https://github.com/phpstan/phpstan)[![License](https://camo.githubusercontent.com/501a3b1c66e484681648ab8e2603eb16c6a2a80ca433948e310e291dbef24e8a/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f6c2f6465636f64656c6162732f64696374756d3f7374796c653d666c6174)](https://packagist.org/packages/decodelabs/dictum)

### Text formatting tools for PHP

[](#text-formatting-tools-for-php)

Dictum provides a collection of commonly required text parsing and processing features.

---

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

[](#installation)

This package requires PHP 8.4 or higher.

Install via Composer:

```
composer require decodelabs/dictum
```

Usage
-----

[](#usage)

### Formatters

[](#formatters)

The root Dictum class exposes a set of predictable text / key formatters which can be used to quickly prepare strings for specific actions.

```
use DecodeLabs\Dictum;

echo Dictum::name('geoff-randomName');
// Geoff Random Name

echo Dictum::firstName('geoff-randomName');
// Geoff

echo Dictum::initials('geoff-randomName');
// GRN

echo Dictum::initialsAndSurname('geoff-randomName');
// GR Name

echo Dictum::initialMiddleNames('geoff-randomName');
// Geoff R Name

echo Dictum::consonants('here\'s a Random-string of text');
// hr's  Rndm-strng f txt

echo Dictum::label('here\'s a Random-string of text');
// Here's a random string of text

echo Dictum::id('here\'s a Random-string of text');
// HeresARandomStringOfText

echo Dictum::camel('here\'s a Random-string of text');
// heresARandomStringOfText

echo Dictum::constant('here\'s a Random-string of text');
// HERE_S_A_RANDOM_STRING_OF_TEXT

echo Dictum::slug('here\'s a Random-string of text / other stuff');
// heres-a-random-string-of-text-other-stuff

echo Dictum::pathSlug('here\'s a Random-string of text / other stuff');
// heres-a-random-string-of-text/other-stuff

echo Dictum::actionSlug('here\'s a Random-string of text / other stuff');
// here's-a-random-string-of-text-/-other-stuff

echo Dictum::fileName('here\'s a Random-string of text / other stuff');
// here's-a-Random-string-of-text-_-other-stuff

echo Dictum::shorten('here\'s a Random-string of text / other stuff', 10);
// here's a…

echo Dictum::numericToAlpha(23345452);
// aybfra

echo Dictum::alphaToNumeric('aybfra')
// 23345452

echo Dictum::toBoolean('yes') ? 'true' : 'false';
// true
```

### Text

[](#text)

The formatters above predominantly use the `Text` class to process the strings provided. This class exposes a full suite of multibyte aware string manipulation functionality in an immutable collection format.

For example, the above `id()` method is defined as:

```
echo (new Text($id))
    ->toUtf8()
    ->toAscii()
    ->regexReplace('([^ ])([A-Z])', '\\1 \\2')
    ->replace(['-', '.', '+'], ' ')
    ->regexReplace('[^a-zA-Z0-9_ ]', '')
    ->toTitleCase()
    ->replace(' ', '')
    ->__toString();
```

Note, regexes are based off the mb\_ereg functions and as such do not use delimiters in their patterns.

Cosmos extensions
-----------------

[](#cosmos-extensions)

Cosmos provides generic interfaces for defining locale-aware formatter extensions that can be implemented by different output generators.

Currently, Time and Number are available, defining predictable methods for formatting dates and various forms of number.

Dictum offers a plain text version of these interfaces:

```
use DecodeLabs\Dictum\Number;
use DecodeLabs\Dictum\Time;

// Custom format
Time::format('now', 'd/m/Y', 'Europe/London');

// Locale format
// When timezone is true it is fetched from Cosmos
Time::locale('now', 'long', 'long', true);

// Locale shortcuts
Time::dateTime('tomorrow'); // medium
Time::longTime('yesterday');
Time::shortDate('yesterday');
// ...etc

// Intervals
Time::since('yesterday'); // 1 day ago
Time::until('tomorrow'); // 1 day from now
Time::sinceAbs('yesterday'); // 1 day
Time::untilAbs('yesterday'); // -1 day
Time::between('yesterday', 'tomorrow'); // 1 day

// Numbers
Number::format(16.5, 'px'); // 16.5 px
Number::format(16.5, 'px', 'de'); // 16,5 px
Number::decimal(16.534643, 2); // 16.53
Number::currency(16.534643, 'GBP'); // £16.53
Number::percent(16.534643, 50, 2); // 33.07%
Number::scientific(16.534643); // 1.6534643E1
Number::spellout(16.534643); // sixteen point five three four six four three
Number::ordinal(16.534643); // 17th
Number::diff(16.534643); // ⬆ 16.535
Number::fileSize(16534643); // 15.77 MiB
Number::fileSizeDec(16534643); // 16.53 MB
```

See [Tagged](https://github.com/decodelabs/tagged) for equivalent HTML implementations of these interfaces.

Licensing
---------

[](#licensing)

Dictum is licensed under the MIT License. See [LICENSE](./LICENSE) for the full license text.

###  Health Score

52

—

FairBetter than 96% of packages

Maintenance76

Regular maintenance activity

Popularity29

Limited adoption so far

Community16

Small or concentrated contributor base

Maturity72

Established project with proven stability

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

Recently: every ~11 days

Total

40

Last Release

273d ago

PHP version history (4 changes)v0.1.0PHP ^7.2|^8.0

v0.4.0PHP ^8.0

v0.6.0PHP ^8.1

v0.6.9PHP ^8.4

### Community

Maintainers

![](https://www.gravatar.com/avatar/8a241d64d12b3b5ee94197862ec1ec30b82ed2efa34a0cd7f4c3565a021daddd?d=identicon)[betterthanclay](/maintainers/betterthanclay)

---

Top Contributors

[![betterthanclay](https://avatars.githubusercontent.com/u/1273586?v=4)](https://github.com/betterthanclay "betterthanclay (220 commits)")

---

Tags

dateformattingnumberphptext-formattingformattext

### Embed Badge

![Health badge](/badges/decodelabs-dictum/health.svg)

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

###  Alternatives

[symfony/dom-crawler

Eases DOM navigation for HTML and XML documents

4.1k399.9M2.6k](/packages/symfony-dom-crawler)[friendsofphp/php-cs-fixer

A tool to automatically fix PHP code style

13.5k251.2M25.2k](/packages/friendsofphp-php-cs-fixer)[symfony/filesystem

Provides basic utilities for the filesystem

4.6k710.3M4.0k](/packages/symfony-filesystem)[symfony/console

Eases the creation of beautiful and testable command line interfaces

9.8k1.1B13.9k](/packages/symfony-console)[symfony/symfony

The Symfony PHP framework

31.4k87.2M2.2k](/packages/symfony-symfony)[symfony/http-foundation

Defines an object-oriented layer for the HTTP specification

8.7k929.1M6.5k](/packages/symfony-http-foundation)

PHPackages © 2026

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