PHPackages                             phrity/util-transformer - 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. phrity/util-transformer

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

phrity/util-transformer
=======================

Type transformers, normalizers and resolvers.

1.3.1(5mo ago)08.9k↑2220%4MITPHPPHP ^8.1CI passing

Since Apr 28Pushed 5mo ago1 watchersCompare

[ Source](https://github.com/sirn-se/phrity-util-transformer)[ Packagist](https://packagist.org/packages/phrity/util-transformer)[ Docs](https://phrity.sirn.se/util-transformer)[ RSS](/packages/phrity-util-transformer/feed)WikiDiscussions main Synced 1mo ago

READMEChangelog (6)Dependencies (8)Versions (7)Used By (4)

[![Phrity Util Transformer](docs/logotype.png)](docs/logotype.png)

[![Build Status](https://github.com/sirn-se/phrity-util-transformer/actions/workflows/acceptance.yml/badge.svg)](https://github.com/sirn-se/phrity-util-transformer/actions)[![Coverage Status](https://camo.githubusercontent.com/4a7c03ac1d70d775392d6cc22c0e0fec4a5a8cca19f6a75b696dc3edcdbcd744/68747470733a2f2f636f766572616c6c732e696f2f7265706f732f6769746875622f7369726e2d73652f7068726974792d7574696c2d7472616e73666f726d65722f62616467652e7376673f6272616e63683d6d61696e)](https://coveralls.io/github/sirn-se/phrity-util-transformer?branch=main)

Introduction
============

[](#introduction)

Type transformers, normalizers and resolvers.

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

[](#installation)

Install with [Composer](https://getcomposer.org/);

```
composer require phrity/util-transformer

```

How to use
==========

[](#how-to-use)

All transformers exposes `canTransform()` and `transform()` methods.

This allows us to transform data of a certain type to another type. A specific transformer may not be able to transform all types.

```
$transformer = new BasicTypeConverter();
if ($transformer->canTransform($subject)) {
    $transformed = transformer->transform($subject);
}
```

As option, a transformer can take a target type specifier as second argument.

```
$transformer = new BasicTypeConverter();
if ($transformer->canTransform($subject, Type::ARRAY)) {
    $transformed = transformer->transform($subject, Type::ARRAY);
}
```

Utility resolvers enable stacking multiple transformers and performing other tasks.

```
$transformer = new RecursionResolver(
    new FirstMatchResolver([
        new EnumConverter(),
        new ReadableConverter(),
        new ThrowableConverter(),
        new StringableConverter(),
        new BasicTypeConverter(),
    ])
);
if ($transformer->canTransform($subject, Type::STRING)) {
    $transformed = transformer->transform($subject, Type::STRING);
}
```

List of transformers in this library
====================================

[](#list-of-transformers-in-this-library)

Encoders &amp; Decoders
-----------------------

[](#encoders--decoders)

- **[Flatten Decoder](docs/codecs/FlattenDecoder.md)** - Expands array with flattened keys to nested array
- **[Json Decoder](docs/codecs/JsonDecoder.md)** - Decodes JSON string

Type converters
---------------

[](#type-converters)

- **[Basic Type](docs/converters/BasicType.md)** - Support transforming all PHP types to all other types
- **[DateTime](docs/converters/DateTime.md)** - Transform DateTime classes to string
- **[Enum](docs/converters/Enum.md)** - Transform Enums to string
- **[Json Serializable](docs/converters/JsonSerializable.md)** - Transform JSON serializable objects
- **[Readable](docs/converters/Readable.md)** - Transform booleans and null to readable strings
- **[Reversed Readable](docs/converters/ReversedReadable.md)** - Transform some strings to boolean and null
- **[Stringable](docs/converters/Stringable.md)** - Transform stringable objects to string
- **[Throwable](docs/converters/Throwable.md)** - Transform throwable to object, array or string

Utility resolvers
-----------------

[](#utility-resolvers)

- **[Chained](docs/resolvers/Chained.md)** - Collection of transformers that will send output from one into next one
- **[First Match](docs/resolvers/FirstMatch.md)** - Collection of transformers that will use first compatible transformer for transformation
- **[Recursion](docs/resolvers/Recursion.md)** - Will apply transformer recursively
- **[String](docs/resolvers/String.md)** - Fold anything to a string

Wrappers
--------

[](#wrappers)

- **[Symfony Normalizer](docs/wrappers/SymfonyNormalizer.md)** - Wrap class implementing Symfony `NormalizerInterface`

Versions
========

[](#versions)

VersionPHP`1.3``^8.1`Transformer: DateTime, Resolver: Chained, String`1.2``^8.1`Additional transformers`1.1``^8.1`Additional transformers`1.0``^8.1`Initial version

###  Health Score

42

—

FairBetter than 90% of packages

Maintenance71

Regular maintenance activity

Popularity25

Limited adoption so far

Community13

Small or concentrated contributor base

Maturity50

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

Total

6

Last Release

161d ago

### Community

Maintainers

![](https://avatars.githubusercontent.com/u/4255391?v=4)[Sören Jensen](/maintainers/sirn-se)[@sirn-se](https://github.com/sirn-se)

---

Top Contributors

[![sirn-se](https://avatars.githubusercontent.com/u/4255391?v=4)](https://github.com/sirn-se "sirn-se (18 commits)")

---

Tags

phpphp-librarytype-transformernormalizertypetransformerresolver

###  Code Quality

TestsPHPUnit

Static AnalysisPHPStan

Code StylePHP\_CodeSniffer

Type Coverage Yes

### Embed Badge

![Health badge](/badges/phrity-util-transformer/health.svg)

```
[![Health](https://phpackages.com/badges/phrity-util-transformer/health.svg)](https://phpackages.com/packages/phrity-util-transformer)
```

###  Alternatives

[phpoption/phpoption

Option Type for PHP

2.7k541.2M159](/packages/phpoption-phpoption)[symfony/polyfill-intl-normalizer

Symfony polyfill for intl's Normalizer class and related functions

2.1k830.2M36](/packages/symfony-polyfill-intl-normalizer)[jetbrains/phpstorm-stubs

PHP runtime &amp; extensions header files for PhpStorm

1.4k27.7M68](/packages/jetbrains-phpstorm-stubs)[ergebnis/composer-normalize

Provides a composer plugin for normalizing composer.json.

1.1k37.3M2.1k](/packages/ergebnis-composer-normalize)[marc-mabe/php-enum

Simple and fast implementation of enumerations with native PHP

49444.8M97](/packages/marc-mabe-php-enum)[symfony/type-info

Extracts PHP types information.

19751.9M114](/packages/symfony-type-info)

PHPackages © 2026

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