PHPackages                             deetrych/mapping - 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. deetrych/mapping

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

deetrych/mapping
================

Library for mapping objects and nested objects into any form desirable

04[2 issues](https://github.com/matigda/mapping/issues)PHPCI failing

Since Sep 19Pushed 6y ago1 watchersCompare

[ Source](https://github.com/matigda/mapping)[ Packagist](https://packagist.org/packages/deetrych/mapping)[ RSS](/packages/deetrych-mapping/feed)WikiDiscussions master Synced 3d ago

READMEChangelogDependenciesVersions (1)Used By (0)

Mapping library
===============

[](#mapping-library)

This library is created to improve mapping data from one form to another.

It was created during struggle with not-so-clean mapping from ( and to ) Elasticsearch and Redis.

It allows you to ommit all the "getters" and create flat structures to save anywhere.

It also allows you to create flat view objects from the data

Read model mappers
------------------

[](#read-model-mappers)

Read model mapper role is to create specific objects and fill it with given data.

Example:

```
use Deetrych\Mapping\Mapper\ReadModel\Factory;

$factory = new Factory(
    [
        ['model' => FlatProduct::class, 'type' => 'array', 'fields' => ['price' => 'product.value', 'currency' => 'product.currency']],
        ['model' => FlatProduct::class, 'type' => 'json', 'fields' => ['priceValue' => 'product.value']],
    ],
    [
        'array' => ArrayMapper::class,
        'json' => JsonMapper::class
    ]
);
$arrayMapper = $factory->createFromType('array');
$result = $arrayMapper->map(['product' => ['value' => 100, 'currency' => 'GBP']);

var_dump($result);

// $result would be
// object(FlatProduct)#23 (3) {
//     ["price":"FlatProduct":private]=>
//     100
//     ["currency":"FlatProduct":private]=>
//     GBP
//   }
```

Write model mappers
-------------------

[](#write-model-mappers)

Write model mapper role is to create specific data structure from given object. You can think about it as a serializer.

Example:

```
use Deetrych\Mapping\Mapper\WriteModel\Factory;

$factory = new Factory(
    new PropertyAccessProvider(),
    [
        ['type' => 'array', 'fields' => ['price' => 'product.price.value', 'currency' => 'product.price.currency']],
        ['type' => 'json', 'fields' => ['priceValue' => 'product.price.value']],
    ],
    [
        'array' => ArrayMapper::class,
        'json' => JsonMapper::class
    ]
);
$arrayMapper = $factory->createFromType('array');
$result = $arrayMapper->map(new Product(new Price(10, 'GBP')));

var_dump($result);

// $result would be
//array(2) {
//     ["price"]=>
//     int(10)
//     ["currency"]=>
//     string(GBP)
//   }
```

###  Health Score

18

—

LowBetter than 8% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity3

Limited adoption so far

Community7

Small or concentrated contributor base

Maturity36

Early-stage or recently created project

 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.

### Community

Maintainers

![](https://www.gravatar.com/avatar/4a729f60aeca247b667f7a0d27383af30e10590e3fb591bbaaff5077fce9e7eb?d=identicon)[matigda](/maintainers/matigda)

---

Top Contributors

[![matigda](https://avatars.githubusercontent.com/u/5388804?v=4)](https://github.com/matigda "matigda (2 commits)")

### Embed Badge

![Health badge](/badges/deetrych-mapping/health.svg)

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

###  Alternatives

[reportico/yii2-reportico

Reportico

2116.5k](/packages/reportico-yii2-reportico)[pishran/laravel-persian-string

Convert Arabic/English/etc numbers and characters to Persian numbers and characters in Laravel models.

206.7k](/packages/pishran-laravel-persian-string)

PHPackages © 2026

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