2017 © Pedro Peláez
 

library transformer

Data Transformer to Transform data from API response to arrays or objects

image

gwsn/transformer

Data Transformer to Transform data from API response to arrays or objects

  • Monday, April 23, 2018
  • by xleeuwx
  • Repository
  • 1 Watchers
  • 0 Stars
  • 262 Installations
  • PHP
  • 2 Dependents
  • 0 Suggesters
  • 0 Forks
  • 0 Open issues
  • 10 Versions
  • 115 % Grown

The README.md

Transformer Package

Installation

Require this package, (*1)

composer require gwsn/transformer

Frameworks specific packages

  1. Lumen/Laravel composer require gwsn/lumen-transformer
  2. Symfony composer require gwsn/symfony-transformer

Simple example

Include the Transformer class:, (*2)

use Gwsn\Transformer\Transformer;, (*3)

In this use case we work only with arrays., (*4)

$source = [
    [
        'id'   => '1',
        'name' => 'Test 1',
        'type' => 'text',
        'text' => 'Some text written by Cicero that's used to fill spaces on.'
    ],
    [
        'id'   => '2',
        'name' => 'Test 2',
        'type' => 'short-text',
        'text' => 'The reason why it is difficult to understand is to draw attention away from the words on a page and to focus it on the design instead.'
    ],
    [
        'id'   => '3',
        'name' => 'Test 3',
        'type' => 'text',
        'text' => 'It's also useful for filling spaces where text should be because its words are about the same length as normal English writing.'
    ],
];

$mapping = [
    'guid' => 'id',
    'slug' => 'name',
    'type' => 'type',
    'text' => 'text',
];

$target = Transformer::run($source, Transformer::BuildMapping($mapping));

var_dump(json_encode($target)); 
output:

 [
     {
         guid: "1",
         slug: "Test Company mapper 1",
         type: "company",
         text: "asdasdfafa afad afads aadssafdf astext"
     },
     {
         guid: "2",
         slug: "Test Company mapper 2",
         type: "blog",
         text: "asdasdfafa afad afads aadssafdf astext"
     },
     {
         guid: "3",
         slug: "Test Company mapper 3",
         type: "company",
         text: "asdasdfafa afad afads aadssafdf astext"
     }
 ]

For the more advanced documentation about the usage you can find it here documentation, (*5)

The Versions

23/04 2018

dev-master

9999999-dev https://www.globalwebsystems.nl

Data Transformer to Transform data from API response to arrays or objects

  Sources   Download

MIT

The Requires

  • php >=7.0

 

mapping api response transformer

23/04 2018

1.0.7

1.0.7.0 https://www.globalwebsystems.nl

Data Transformer to Transform data from API response to arrays or objects

  Sources   Download

MIT

The Requires

  • php >=7.0

 

mapping api response transformer

18/04 2018

1.0.6

1.0.6.0 https://www.globalwebsystems.nl

Data Transformer to Transform data from API response to arrays or objects

  Sources   Download

MIT

The Requires

  • php >=7.0

 

mapping api response transformer

18/04 2018

1.0.5

1.0.5.0 https://www.globalwebsystems.nl

Data Transformer to Transform data from API response to arrays or objects

  Sources   Download

MIT

The Requires

  • php >=7.0

 

mapping api response transformer

18/04 2018

1.0.4

1.0.4.0 https://www.globalwebsystems.nl

Data Transformer to Transform data from API response to arrays or objects

  Sources   Download

MIT

The Requires

  • php >=7.0

 

mapping api response transformer

14/03 2018

1.0.3

1.0.3.0 https://www.globalwebsystems.nl

Data Transformer to Transform data from API response to arrays or objects

  Sources   Download

MIT

The Requires

  • php >=7.0

 

mapping api response transformer

14/03 2018

dev-develop

dev-develop https://www.globalwebsystems.nl

Data Transformer to Transform data from API response to arrays or objects

  Sources   Download

MIT

The Requires

  • php >=7.0

 

mapping api response transformer

14/03 2018

1.0.2

1.0.2.0 https://www.globalwebsystems.nl

Data Transformer to Transform data from API response to arrays or objects

  Sources   Download

MIT

The Requires

  • php >=7.0

 

mapping api response transformer

14/03 2018

1.0.1

1.0.1.0 https://www.globalwebsystems.nl

Data Transformer to Transform data from API response to arrays or objects

  Sources   Download

MIT

The Requires

  • php >=7.0

 

mapping api response transformer

14/03 2018

1.0

1.0.0.0 https://www.globalwebsystems.nl

Data Transformer to Transform data from API response to arrays or objects

  Sources   Download

MIT

The Requires

  • php >=7.0

 

mapping api response transformer