PHPackages                             askoldex/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. askoldex/formatter

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

askoldex/formatter
==================

PHP text formatting

1.0.3(6y ago)11.2k4MITPHP

Since Jul 13Pushed 6y agoCompare

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

READMEChangelog (4)DependenciesVersions (5)Used By (4)

### Installation

[](#installation)

`composer require askoldex/formatter`

### Usage

[](#usage)

```
use Askoldex\Formatter\Formatter;

class Engine
{
    public $position = [
        'x' => 1.5,
        'y' => 78,
        'z' => 56
    ];

    public function vendor()
    {
        return 'Mitsubishi Motors';
    }
}

class Car
{
    public $model = 'lancer';
    public $ls = 98;
    public $modification;
    public $color = 'green';

    public function engine()
    {
        return new Engine();
    }
}
/*
 * Init Formatter without default associations
 */
$formatter = new Formatter();

/*
 * Init Formatter with default associations
 */
$formatter = new Formatter(['car' => new Car()]);

/*
 * Associate var "car" with object Car
 */
$formatter->associate('car', new Car());
$price = 5000;
$formatter->associate('price', $price);
/*
 * If property or method always exists and has value,
 * use construction: {object.foo.bar}
 */
$text = $formatter->format('Car model: {car.model}');
echo $text.PHP_EOL; //Car model: lancer

/*
 * If property or method always exists and may have and empty value,
 * use construction: {object.foo.bar?default value}
 */
$text = $formatter->format('Car modification: {car.modification?default value}');
echo $text.PHP_EOL; //Car modification: default value

/*
 * If property or method always exists and may have an empty value,
 * and if you want to use object as default value,
 * use construction: {object.foo.bar?+object.bar}
 *
 */
$text = $formatter->format('Car ls: {car.modification?+car.ls}');
echo $text.PHP_EOL; //Car ls: 98

/*
 * If property or method may not exists and may have an empty value,
 * use construction: {object.wrong.property.or.method|default value}
 *
 */
$text = $formatter->format('Car model: {car.wrong|field is empty}');
echo $text.PHP_EOL; // Car model: field is empty

/*
 * If property or method may not exists and may have an empty value,
 * and if you want to use object as default value,
 * use construction: {object.wrong.property.or.method|+object.field}
 *
 */
$text = $formatter->format('Car color: {car.wrong|+car.color}');
echo $text.PHP_EOL; // Car color: green

/*
 * More examples
 */

$text = $formatter->format("
Engine position:
x: {car.engine.position.x}
y: {car.engine.position.y}
z: {car.engine.position.z}
Engine vendor: {car.engine.vendor}
");
echo $text.PHP_EOL;

$text = $formatter->format('Price: {price}$');
echo $text.PHP_EOL;
```

###  Health Score

30

—

LowBetter than 64% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity17

Limited adoption so far

Community8

Small or concentrated contributor base

Maturity62

Established project with proven stability

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

Total

4

Last Release

2224d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/78d1dc15f773d4aff0391c68652cfeecd2a3a9fd36c0cab275500b64feaf5b00?d=identicon)[askoldex](/maintainers/askoldex)

### Embed Badge

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

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

###  Alternatives

[kenjis/codeigniter-composer-installer

Package to install CodeIgniter3 via Composer with secure folder structure.

37561.8k](/packages/kenjis-codeigniter-composer-installer)

PHPackages © 2026

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