mohmann/array-transform

Transforms raw arrays from a given source mapping and back again

v0.0.3 2018-07-24 07:21 UTC

This package is auto-updated.

Last update: 2024-12-22 01:20:26 UTC


README

Latest Stable Version Build Status Coverage Status License PHP 7.1+

Transforms raw arrays from a given source mapping to a target mapping and back again.

This package requires PHP 7.1 or higher.

Quick example. Given the following YAML mapping:

---
mapping:
  foo[int]:
    inverse: bar.baz[float]
    formula:
      direct: bar.baz / 1000
      inverse: foo * 1000

A php array that looks like this (1):

[
    'bar' [
        'baz' => 1000.0
    ],
];

... transforms to this (2) (transform):

[
    'foo' => 1;
];

... and can be transformed back to its original form (reverseTransform)*

[
    'bar' [
        'baz' => 1000.0
    ],
];

Simple formulas and type definitions are some of the "advanced" features of array-transform. Please refer to the documentation for more details.

*There are weird mapping cases where a reverseTransform is not possible. Refer to the documentation for details.

Installation

Via composer:

composer require mohmann/array-transform

Usage

WIP. Check the examples/ directory for now.

Documentation

WIP. Check the doc/ directory for a mapping example.

Development / Testing

Refer to the Makefile for helpful commands, e.g.:

make stan
make test
make inf

License

array-transform is released under the MIT License. See the bundled LICENSE file for details.