Download the PHP package dazet/data-map without Composer

On this page you can find all versions of the php package dazet/data-map. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.

FAQ

After the download, you have to make one include require_once('vendor/autoload.php');. After that you have to import the classes with use statements.

Example:
If you use only one package a project is not needed. But if you use more then one package, without a project it is not possible to import the classes with use statements.

In general, it is recommended to use always a project to download your libraries. In an application normally there is more than one library needed.
Some PHP packages are not free to download and because of that hosted in private repositories. In this case some credentials are needed to access such packages. Please use the auth.json textarea to insert credentials, if a package is coming from a private repository. You can look here for more information.

  • Some hosting areas are not accessible by a terminal or SSH. Then it is not possible to use Composer.
  • To use Composer is sometimes complicated. Especially for beginners.
  • Composer needs much resources. Sometimes they are not available on a simple webspace.
  • If you are using private repositories you don't need to share your credentials. You can set up everything on our site and then you provide a simple download link to your team member.
  • Simplify your Composer build process. Use our own command line tool to download the vendor folder as binary. This makes your build process faster and you don't need to expose your credentials for private repositories.
Please rate this library. Is it a good library?

Informations about the package data-map

Data Mapper

Library for mapping and transforming data structures.

Build Status

Defining mapper

Mapper configuration is a description of output structure defined as association:

Key defines property name in output structure and Getter is a function that extracts value from input.

Examples

Getter function

Getter generally can be described as interface:

There are 2 forms of defining map:

Predefined Getters

new GetRaw($key, $default)

Get value by property path without additional transformation.

new GetString($key, $default)

Gets value and casts to string (if possible) or returns $default.

new GetInteger($key, $default)

Gets value and casts to integer (if possible) or $default.

new GetFloat($key, $default)

Gets value and casts to float (if possible) or $default.

new GetBoolean($key, $default)

Gets value and casts to boolean (true, false, 0, 1, '0', '1') or $default.

new GetDate($key, $default)

Gets value and transform to \DateTimeImmutable (if possible) or $default.

new GetJoinedStrings($glue, $key1, $key2, ...)

Gets string value for given keys an join it using $glue.

new GetMappedCollection($key, $callback)

Gets collection under given $key and maps it with $callback or return [] if entry cannot be mapped.

new GetMappedFlatCollection($key, $callback)

Similar to GetMappedCollection but result is flattened.

new GetTranslated($key, $map, $default)

Gets value and translates it using provided associative array ($map) or $default when translation for value is not available.

GetFiltered::from('key')->...

Gets value and transforms it through filters pipeline.

Using function as filter:

Regular filters will not be called when value becomes null, with exceptions of ifNull, ifEmpty and withNullable.

Custom null handling filter:

GetFiltered has set of built-in filters similar to FilteredInput.

Input abstraction

Input interface defines common abstraction for accessing data from different data structures, so mapping and getters must not depend of underlying data type.

It also allows to create input decorators for additional input processing, like data filtering, transformation, traversing etc.

ArrayInput

Wraps associative arrays and ArrayAccess objects.

ObjectInput

Wraps generic object and fetches data using object public interface: public properties or getters (a public method without parameters that returns some value).

Access method for key example name is resolved in the following order:

RecursiveInput

RecursiveInput allows to traverse trees od data using dot notation ($input->get('root.branch.leaf')). It decorates Input (current leaf) and requires Wrapper to wrap with proper Input next visited leafs (which can be arrays or objects).

FilteredInput

FilteredInput is another Input decorator that allows to transform data after it is extracted from inner structure.

Default input parser supports given filters:

Examples

Function as transformation

Default configuration of InputFilterParser allows use any PHP function as transformation. By default mapped value is passed as first argument to that function optionally followed by other arguments defined in filter config. It is also possible to define different argument position of mapped value using $$ as a placeholder.

Output formatting

Mapping output type depends on Formatter used by Mapper.

Built-in formatters:

ArrayFormatter

Returns associative array which is raw result of Mapper transformation.

ObjectConstructor

Tries to create new instance of object using regular constructor. Keys are matched with constructor parameters by variable name.

There is no value type and correctness checking, so you will get TypeError when mapped types does not match. It also fallback to null value when object constructor has parameter that is not in the mapping.

ObjectHydrator

Tries to hydrate instance of object using his public interface, that is:

Customizing and extending

Mapper consists of 3 components:

Implement Input and Wrapper to extract data from specific sources

It is possible to define data extracting for some object type explicitly.

Use only MixedWrapper for better performance

By default Mapper supports nested structure fetching and value filters, which is nice but has some expense in performance (see BENCHMARK.md). But it is possible to create Mapper only with MixedWrapper when these feature are not needed.

Custom filters for FilteredInput

Filter functions list can be extended or overwritten with own implementation.

Custom Formatter

Custom formatter can be used to achieve better object construction performance than generic object formatters. It is also possible to create formatters creating different result types like XML, JSON etc.


All versions of data-map with dependencies

PHP Build Version
Package Version
Requires php Version >=7.2
ext-json Version *
ext-ctype Version *
Composer command for our command line client (download client) This client runs in each environment. You don't need a specific PHP version etc. The first 20 API calls are free. Standard composer command

The package dazet/data-map contains the following files

Loading the files please wait ....