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

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

urmaul/formatter
================

Rule-based string format.

v1.5.0(10y ago)01511MITPHPPHP &gt;=5.3

Since Aug 7Pushed 10y agoCompare

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

READMEChangelogDependencies (1)Versions (8)Used By (0)

Formatter
=========

[](#formatter)

Rule-based string formatters. Made for polishing parsed data.

[![Build Status](https://camo.githubusercontent.com/c777b3b3f9eac5cf2aae4afc162445bbb28017d81608040504775002085e57eb/68747470733a2f2f7472617669732d63692e6f72672f75726d61756c2f75726c2e737667)](https://travis-ci.org/urmaul/formatter)[![Latest Stable Version](https://camo.githubusercontent.com/36f5c35acdbf229dafdb9ef172ff5a4eaf9a082167ac36c408864fd79e9f4811/68747470733a2f2f706f7365722e707567782e6f72672f75726d61756c2f666f726d61747465722f762f737461626c652e737667)](https://packagist.org/packages/urmaul/formatter)[![Total Downloads](https://camo.githubusercontent.com/418cea8851186818aa526c8e0e627aa30afa98e58a9af7a2bd755f736a1ab916/68747470733a2f2f706f7365722e707567782e6f72672f75726d61756c2f666f726d61747465722f646f776e6c6f6164732e737667)](https://packagist.org/packages/urmaul/formatter)[![Latest Unstable Version](https://camo.githubusercontent.com/b2f12fb9de84279630b8286aa8b920aab89fc06f8aab517469b6d272449fc6dd/68747470733a2f2f706f7365722e707567782e6f72672f75726d61756c2f666f726d61747465722f762f756e737461626c652e737667)](https://packagist.org/packages/urmaul/formatter)[![License](https://camo.githubusercontent.com/ea5f2d9ef0e19a3f2e27a903f85248398a906b676e54633bb2e091eaf91e1945/68747470733a2f2f706f7365722e707567782e6f72672f75726d61756c2f666f726d61747465722f6c6963656e73652e737667)](https://packagist.org/packages/urmaul/formatter)

Installing
----------

[](#installing)

`composer require urmaul/formatter dev-master`

Using
-----

[](#using)

```
$values = ['foo' => '  bar  ', 'spam' => 'ham | foo | bar'];

$formatter = new Formatter([
    ['foo', 'trim'],
    ['spam', 'cut', ' | '],
]);
$values = $formatter->format($values);

// $values = ['foo' => 'bar', 'spam' => 'ham'];
```

Actions
-------

[](#actions)

- **cut(delimiter)** - returns string part between beginning and delimiter.
- **rcut(delimiter)** - returns string part between delimiter and ending.
- **remove(substring)** - removes substring. See [str\_replace](http://www.php.net/manual/en/function.str-replace.php).
- **replace(substring, replacement)** - replaces substring with replacement. See [str\_replace](http://www.php.net/manual/en/function.str-replace.php).
- **removeMatch(pattern)** - removes pattern. See [preg\_replace](http://www.php.net/manual/en/function.preg-replace.php).
- **replaceMatch(pattern, replacement)** - replaces pattern with replacement. See [preg\_replace](http://www.php.net/manual/en/function.preg-replace.php).
- **map(array map)** - replaces string with value from map.
- **between(leftBorder, rightBorder)** - returns string part between first occurence of leftBorder and rightBorder.
- **trim(\[character\_mask = " \\t\\n\\r\\0\\x0B"\])** - strips whitespace (or other characters) from the beginning and end of a string.
- **callback(callable)** - processes string with callback.
- **grep(substring)** - returns lines containing substring.
- **stripTags(\[allowable\_tags\])** - strips HTML and PHP tags from a string. See [strip\_tags](http://www.php.net/manual/en/function.strip-tags.php).
- **iconv(\[encoding\_from, encoding\_to\])** - converts character encoding. Defaults are "UTF-8" - "UTF-8//IGNORE" which remove invalid characters from utf-8 string.
- **stripWhitespaces(string)** - returns string without unprintable characters.

###  Health Score

28

—

LowBetter than 51% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity11

Limited adoption so far

Community7

Small or concentrated contributor base

Maturity63

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

Recently: every ~105 days

Total

7

Last Release

3950d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/22364b943477de78bf89bb19b5708a93666e38b5f1ad954ded9c656b3c116cb8?d=identicon)[urmaul](/maintainers/urmaul)

---

Top Contributors

[![andriibond](https://avatars.githubusercontent.com/u/6419644?v=4)](https://github.com/andriibond "andriibond (8 commits)")

---

Tags

formatterstringformat

###  Code Quality

TestsPHPUnit

### Embed Badge

![Health badge](/badges/urmaul-formatter/health.svg)

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

###  Alternatives

[nette/utils

🛠 Nette Utils: lightweight utilities for string &amp; array manipulation, image handling, safe JSON encoding/decoding, validation, slug or strong password generating etc.

2.1k443.7M1.8k](/packages/nette-utils)[willdurand/negotiation

Content Negotiation tools for PHP provided as a standalone library.

1.4k131.4M232](/packages/willdurand-negotiation)[hallindavid/manny

a package of manipulators that hopefully come in useful for those of us who always forget regex when we need it (manny is short for manipulation)

37110.6k3](/packages/hallindavid-manny)[opis/string

Multibyte strings as objects

7728.9M9](/packages/opis-string)[phootwork/lang

Missing PHP language constructs

1229.3M8](/packages/phootwork-lang)

PHPackages © 2026

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