alexmcarrow / datamapper
Data Mapper Class
dev-main
2022-12-05 13:08 UTC
Requires
- php: ^8.0
- ext-mbstring: *
Requires (Dev)
- phpunit/phpunit: ^9.5.26
- vimeo/psalm: ^5.1
This package is auto-updated.
Last update: 2024-12-05 17:18:23 UTC
README
Class for mapping data by filters
Instalation
composer require alexmcarrow/datamapper
Using
use AlexMcArrow\DataMapper\DataMapper; new DataMapper(); DataMapper::setFieldsFilter([ 'key' => 'KeyID', 'name' => 'User Name' ]); $rawdata = [ [ 'key' => 'a1', 'name' => 'Alex', 'email' => 'alex@domain.tld' ], [ 'key' => 'b2', 'name' => 'Axel' ] ]; $cleardata = DataMapper::parseMapData($rawdata, DataMapper::$FILTER_PASS_CUT, DataMapper::$FILTER_TYPE_HARD, DataMapper::$MAP_KEY, DataMapper::$MAP_VALUE); print_r($cleardata);
[ [ 'keyid' => 'a1', 'user name' => 'Alex' ], [ 'keyid' => 'b2', 'user name' => 'Axel' ] ]
License
MIT