PHP Classes

PHP Data Mapper: Map array values with data mapper filters

Recommend this page to a friend!

  Author Author  
Picture of Alex McArrow
Name: Alex McArrow <contact>
Classes: 3 packages by
Country: Russian Federation Russian Federation
Age: 39
All time rank: 4097115 in Russian Federation Russian Federation
Week rank: 514 Up25 in Russian Federation Russian Federation Up
Innovation award
Innovation award
Nominee: 2x

Winner: 1x


  Detailed description   Download Download .zip .tar.gz  
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

Details

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


  Classes of Alex McArrow  >  PHP Data Mapper  >  Download Download .zip .tar.gz  >  Support forum Support forum  >  Blog Blog (1)  >  RSS 1.0 feed RSS 2.0 feed Latest changes  
Name: PHP Data Mapper
Base name: datamapper
Description: Map array values with data mapper filters
Version: 0.0.0
PHP version: 8
License: The PHP License
All time users: 69 users
All time rank: 10150
Week users: 0 users
Week rank: 257 Equal
 
  Groups   Rate classes User ratings   Applications   Files Files  

  Groups  
Group folder image Data types Modeling and manipulating data types View top rated classes
Group folder image Validation Validation algorithms View top rated classes
Group folder image PHP 8 Classes using PHP 8 specific features View top rated classes


  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

  User ratings  
Not yet rated by the users

  Applications that use this package  
No pages of applications that use this class were specified.

Add link image If you know an application of this package, send a message to the author to add a link here.

  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

Download Download all files: datamapper.tar.gz datamapper.zip
NOTICE: if you are using a download manager program like 'GetRight', please Login before trying to download this archive.
  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

Download Download all files: datamapper.tar.gz datamapper.zip
NOTICE: if you are using a download manager program like 'GetRight', please Login before trying to download this archive.