PHP Classes

File: README.md

Recommend this page to a friend!
  Classes of Alex McArrow   PHP Data Mapper   README.md   Download  
File: README.md
Role: Documentation
Content type: text/markdown
Description: Documentation
Class: PHP Data Mapper
Map array values with data mapper filters
Author: By
Last change:
Date: 1 year ago
Size: 823 bytes
 

Contents

Class file image Download

DataMapper

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