PHPackages                             cndrsdrmn/php-string-formatter - 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. cndrsdrmn/php-string-formatter

ActiveLibrary

cndrsdrmn/php-string-formatter
==============================

Provides utilities to format strings by replacing specific wildcards with randomly generated characters

v0.2.0(1y ago)04051MITPHPPHP ^8.3

Since Nov 27Pushed 1y ago1 watchersCompare

[ Source](https://github.com/cndrsdrmn/php-string-formatter)[ Packagist](https://packagist.org/packages/cndrsdrmn/php-string-formatter)[ RSS](/packages/cndrsdrmn-php-string-formatter/feed)WikiDiscussions master Synced 1mo ago

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

PHP String Formatter
====================

[](#php-string-formatter)

The `php-string-formatter` package provides a simple and efficient way to generate formatted strings by replacing placeholders (`#`, `?`, `*`, `%`) with random characters, numbers, or a mix of both. It's perfect for creating test data, unique codes, or flexible string patterns.

---

Features
--------

[](#features)

- Replace `#` with random digits (0-9).
- Replace `%` with random digits (1-9).
- Replace `?` with random lowercase letters (a-z).
- Replace `*` with random digits or letters.
- Easy integration with PHP projects.

---

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

[](#installation)

Install the package via Composer:

```
composer require cndrsdrmn/php-string-formatter
```

---

Usage
-----

[](#usage)

### Basic Wildcard Replacement

[](#basic-wildcard-replacement)

```
use Cndrsdrmn\PhpStringFormatter\StringFormatter;

// Replace '#' with random digits (0-9)
echo StringFormatter::numerify('Order-###');
// Output: Order-123

// Replace '%' with random digits (1-9)
echo StringFormatter::numerify('Code-%-%-%');
// Output: Code-3-7-8

// Replace '?' with random lowercase letters (a-z)
echo StringFormatter::lexify('User-???');
// Output: User-abc

// Replace '*' with random digits or letters
echo StringFormatter::bothify('Key-***');
// Output: Key-a3b
```

### Advanced Replacement

[](#advanced-replacement)

You can mix and match placeholders in a single string:

```
echo StringFormatter::bothify('Code-#?%-*?#');
// Output: Code-3a9-b1c3
```

---

Supported Placeholders
----------------------

[](#supported-placeholders)

PlaceholderReplacementExample InputExample Output`#`Random digit (0-9)`###``123``%`Random digit (1-9)`%%%``456``?`Random letter (a-z)`???``abc``*`Random digit or letter`***``a1b`---

Methods
-------

[](#methods)

### `numerify(string $string): string`

[](#numerifystring-string-string)

Replaces all `#` with random digits (0-9) and `%` with random digits (1-9).

### `lexify(string $string): string`

[](#lexifystring-string-string)

Replaces all `?` with random lowercase letters (a-z).

### `bothify(string $string): string`

[](#bothifystring-string-string)

Replaces all `*` with random digits (0-9) or letters (a-z).

---

Testing
-------

[](#testing)

This package can be tested with PHPUnit. To run tests:

```
composer test
```

---

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

[](#contributing)

Contributions are welcome! Feel free to fork the repository, submit pull requests, or open issues for suggestions and bug reports.

---

License
-------

[](#license)

This package is open-source software licensed under the [MIT license](LICENSE).

###  Health Score

28

—

LowBetter than 54% of packages

Maintenance38

Infrequent updates — may be unmaintained

Popularity13

Limited adoption so far

Community9

Small or concentrated contributor base

Maturity44

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

Total

2

Last Release

536d ago

### Community

Maintainers

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

---

Top Contributors

[![cndrsdrmn](https://avatars.githubusercontent.com/u/19147653?v=4)](https://github.com/cndrsdrmn "cndrsdrmn (5 commits)")

---

Tags

phpformatterstring

###  Code Quality

TestsPest

Static AnalysisPHPStan, Rector

Code StyleLaravel Pint

Type Coverage Yes

### Embed Badge

![Health badge](/badges/cndrsdrmn-php-string-formatter/health.svg)

```
[![Health](https://phpackages.com/badges/cndrsdrmn-php-string-formatter/health.svg)](https://phpackages.com/packages/cndrsdrmn-php-string-formatter)
```

###  Alternatives

[coduo/php-to-string

Simple library that converts PHP value into strings

27112.7M10](/packages/coduo-php-to-string)[sbsaga/toon

🧠 TOON for Laravel — a compact, human-readable, and token-efficient data format for AI prompts &amp; LLM contexts. Perfect for ChatGPT, Gemini, Claude, Mistral, and OpenAI integrations (JSON ⇄ TOON).

6115.6k](/packages/sbsaga-toon)

PHPackages © 2026

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