PHP Classes

PHP Data Mapper: Map array values with data mapper filters

Recommend this page to a friend!
  Info   View files Documentation   View files View files (7)   DownloadInstall with Composer Download .zip   Reputation   Support forum   Blog (1)    
Ratings Unique User Downloads Download Rankings
Not yet rated by the usersTotal: 76 All time: 10,148 This week: 660Up
Version License PHP version Categories
datamapper 0.0.0The PHP License8Data types, Validation, PHP 8
Description 

Author

This class can map array values with data mapper filters.

It can take an array with one or more associative data value arrays and perform several operations to transform it into the output array.

Currently, it can:

- Remove values of specific columns in all rows

- Take values of the input array with specific keys values and map them to other fundamental values of the output array

Innovation Award
PHP Programming Innovation award nominee
December 2022
Number 3
Some applications need to process arrays that they receive from external sources like database result queries or external Web service API calls.

Sometimes the arrays do not come in the best format for those applications to process. Therefore they need to process the arrays to transform their values.

This package provides a way to transform the input arrays into other arrays that may have changed the key names of associative arrays or eliminated the array values with specific keys.

Manuel Lemos
Picture of Alex McArrow
  Performance   Level  
Name: Alex McArrow <contact>
Classes: 3 packages by
Country: Russian Federation Russian Federation
Age: 40
All time rank: 4092115 in Russian Federation Russian Federation
Week rank: 295 Up16 in Russian Federation Russian Federation Up
Innovation award
Innovation award
Nominee: 2x

Winner: 1x

Documentation

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


  Files folder image Files  
File Role Description
Files folder imagesrc (1 file)
Files folder imagetests (1 file)
Accessible without login Plain text file composer.json Data Auxiliary data
Accessible without login Plain text file composer.lock Data Auxiliary data
Accessible without login Plain text file phpunit.xml Data Auxiliary data
Accessible without login Plain text file psalm.xml Data Auxiliary data
Accessible without login Plain text file README.md Doc. Documentation

  Files folder image Files  /  src  
File Role Description
  Plain text file DataMapper.php Class Class source

  Files folder image Files  /  tests  
File Role Description
  Plain text file DataMapperTest.php Class Class source

 Version Control Unique User Downloads Download Rankings  
 100%
Total:76
This week:0
All time:10,148
This week:660Up