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

ActiveLibrary

transformers/mapping-transformer
================================

Integrates Mapper to transform array collections using Mappings.

3.0.2(9mo ago)376.7k↓75%[1 issues](https://github.com/Porter-transformers/MappingTransformer/issues)LGPL-3.0PHPPHP ^8.1CI passing

Since Jan 29Pushed 9mo ago2 watchersCompare

[ Source](https://github.com/Porter-transformers/MappingTransformer)[ Packagist](https://packagist.org/packages/transformers/mapping-transformer)[ RSS](/packages/transformers-mapping-transformer/feed)WikiDiscussions master Synced today

READMEChangelogDependencies (5)Versions (10)Used By (0)

MappingTransformer
------------------

[](#mappingtransformer)

[![Latest version](https://camo.githubusercontent.com/9a1497ddd85a8b2dacce754971619438cc3f00979aca4d74875b19ca0ab6e794/68747470733a2f2f706f7365722e707567782e6f72672f7472616e73666f726d6572732f6d617070696e672d7472616e73666f726d65722f76657273696f6e "Latest version")](https://github.com/Porter-transformers/MappingTransformer/releases)[![Total downloads](https://camo.githubusercontent.com/b310c3401c3d234be9629b068a1bdd61e71f313dcdc7dab4e670b9adcc376fe8/68747470733a2f2f706f7365722e707567782e6f72672f7472616e73666f726d6572732f6d617070696e672d7472616e73666f726d65722f646f776e6c6f616473 "Total downloads")](https://packagist.org/packages/transformers/mapping-transformer)[![Build status](https://github.com/Porter-transformers/MappingTransformer/actions/workflows/Tests.yaml/badge.svg "Build status")](https://github.com/Porter-transformers/MappingTransformer/actions/workflows/Tests.yaml)[![Test coverage](https://camo.githubusercontent.com/dd93386bd9e6c75a3cb5a754ee6b8b485a9f0ca177427503c7d9f86805c06ab8/68747470733a2f2f636f766572616c6c732e696f2f7265706f732f6769746875622f506f727465722d7472616e73666f726d6572732f4d617070696e675472616e73666f726d65722f62616467652e737667 "Test coverage")](https://coveralls.io/github/Porter-transformers/MappingTransformer)[![Code style](https://camo.githubusercontent.com/bb4eed0b4885313820358824e0b3ee44a1ca2ded5509b220a2bd24b9ecc73f63/68747470733a2f2f7374796c6563692e696f2f7265706f732f37363738323136362f736869656c643f7374796c653d666c6174 "Code style")](https://styleci.io/repos/76782166)

MappingTransformer integrates [Mapper](https://github.com/ScriptFUSION/Mapper) into [Porter](https://github.com/ScriptFUSION/Porter) to support data transformations using `Mapping` objects. A full discussion of Mapper is beyond the scope of this document but the linked repository contains comprehensive documentation. MappingTransformer builds on Mapper by providing a powerful mapping strategy called `SubImport`.

### Sub-imports

[](#sub-imports)

The `SubImport` strategy provides a way to join data sets together. A mapping may contain any number of sub-imports, each of which may receive a different `ImportSpecification`. A sub-import causes Porter to begin a new import operation and thus supports all import options without limitation, including importing from different providers and applying a separate mapping to each sub-import.

#### Signature

[](#signature)

```
SubImport(ImportSpecification|callable $specificationOrCallback)
```

1. `$specificationOrCallback` – Either an `ImportSpecification` instance or `callable` that returns such an instance.

#### ImportSpecification Example

[](#importspecification-example)

The following example imports `MyImportSpecification` and copies the *foo* field from the input data into the output mapping. Next it performs a sub-import using `MyDetailsSpecification` and stores the result in the *details* key of the output mapping.

```
$records = $porter->import(
    (new MyImportSpecification)
        ->setMapping(new AnonymousMapping([
            'foo' => new Copy('foo'),
            'details' => new SubImport(MyDetailsSpecification),
        ]))
);
```

#### Callback example

[](#callback-example)

The following example is the same as the previous except `MyDetailsSpecification` now requires an identifier that is copied from *details\_id* present in the input data. This is only possible using a callback since we cannot inject strategies inside specifications.

```
$records = $porter->import(
    (new MyImportSpecification)
        ->setMapping(new AnonymousMapping([
            'foo' => new Copy('foo'),
            'details' => new SubImport(
                function (array $record) {
                    return new MyDetailsSpecification($record['details_id']);
                }
            ),
        ]))
);
```

###  Health Score

47

—

FairBetter than 94% of packages

Maintenance49

Moderate activity, may be stable

Popularity33

Limited adoption so far

Community8

Small or concentrated contributor base

Maturity78

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

Recently: every ~501 days

Total

9

Last Release

288d ago

Major Versions

1.1.0 → 5.0.x-dev2018-04-26

2.1.0 → 3.0.02022-12-07

### Community

Maintainers

![](https://avatars.githubusercontent.com/u/470626?v=4)[Bilge](/maintainers/Bilge)[@Bilge](https://github.com/Bilge)

---

Top Contributors

[![Bilge](https://avatars.githubusercontent.com/u/470626?v=4)](https://github.com/Bilge "Bilge (18 commits)")

---

Tags

data-transformmapperporter

###  Code Quality

TestsPHPUnit

### Embed Badge

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

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

PHPackages © 2026

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