2017 © Pedro Peláez
 

library mapping-transformer

Integrates Mapper to transform array collections using Mappings.

image

transformers/mapping-transformer

Integrates Mapper to transform array collections using Mappings.

  • Thursday, April 26, 2018
  • by Bilge
  • Repository
  • 1 Watchers
  • 2 Stars
  • 4,585 Installations
  • PHP
  • 0 Dependents
  • 1 Suggesters
  • 0 Forks
  • 0 Open issues
  • 6 Versions
  • 9 % Grown

The README.md

MappingTransformer

Latest version Total downloads Build status Test coverage ![Code style][Style image], (*1)

MappingTransformer integrates Mapper into 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., (*2)

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., (*3)

Signature

SubImport(ImportSpecification|callable $specificationOrCallback)
  1. $specificationOrCallback – Either an ImportSpecification instance or callable that returns such an instance.

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., (*4)

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

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., (*5)

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

The Versions

26/04 2018

5.0.x-dev

5.0.9999999.9999999-dev

Integrates Mapper to transform array collections using Mappings.

  Sources   Download

LGPL-3.0

The Requires

 

The Development Requires

by Avatar Bilge

09/04 2018

dev-master

9999999-dev

Integrates Mapper to transform array collections using Mappings.

  Sources   Download

LGPL-3.0

The Requires

 

The Development Requires

by Avatar Bilge

09/04 2018

1.1.0

1.1.0.0

Integrates Mapper to transform array collections using Mappings.

  Sources   Download

LGPL-3.0

The Requires

 

The Development Requires

by Avatar Bilge

28/10 2017

4.0.x-dev

4.0.9999999.9999999-dev

Integrates Mapper to transform array collections using Mappings.

  Sources   Download

LGPL-3.0

The Requires

 

The Development Requires

by Avatar Bilge

13/06 2017

1.0.1

1.0.1.0

Integrates Mapper to transform array collections using Mappings.

  Sources   Download

LGPL-3.0

The Requires

 

The Development Requires

by Avatar Bilge

29/01 2017

1.0.0

1.0.0.0

Integrates Mapper to transform array collections using Mappings.

  Sources   Download

LGPL-3.0

The Requires

 

The Development Requires

by Avatar Bilge