mohmann / array-transform
Transforms raw arrays from a given source mapping and back again
Requires
- php: ^7.1
- symfony/yaml: ^3.4
Requires (Dev)
- friendsofphp/php-cs-fixer: ^2.12
- infection/infection: ^0.9.0
- phake/phake: ^3.1
- phpbench/phpbench: ^0.14.0
- phpmetrics/phpmetrics: ^2.4
- phpstan/phpstan: ^0.10.1
- phpunit/phpunit: ^6.0
- spatie/phpunit-watcher: ^1.5
This package is auto-updated.
Last update: 2024-12-22 01:20:26 UTC
README
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.