oktavlachs/data-mapping-service

A type safe service, which maps raw data structures onto objects the >= PHP 8 way.

0.4.0 2022-12-31 08:07 UTC

This package is auto-updated.

Last update: 2024-04-29 04:13:58 UTC


README

Security Rating Maintainability Rating Reliability Rating Coverage

Vulnerabilities Technical Debt Lines of Code

Licence

The PHP Data Mapping Service type safely maps raw source data onto target objects in a >= PHP 7.4 way: Your target object defines the way it expects source data to match - no need for type validation anymore. On top of that there is almost no use for annotation type hinting anymore.

Supported raw data types: array, stdClass, JSON string, XML string, SimpleXMLElement

supported target object types: mixed, scalar types (string, bool, int, float), user defined objects, stdClass, abstract classes,

arrays: This has to be specified in the target properties doc commen.

Please use the syntax: @var array<arrayKeyType, arrayElementType>

Allowed arrayKeyType -> 'string' or 'int'.

Allowed arrayElementType -> nested array, user specific objects

user specific objects in arrays: You don't have to provide the full namespace. It is fine if you use a use statement for this or (if the user object is in the same namespace as the target objects class), simply provide the short name.

This service is designed with different users in mind (exception handling)... TODO

Table of Contents

Installation

Dependencies

Stable Release

Development Version

Usage

Mappable source data types

This mapping service supports basic data types most of your use cases boil down to:

Source

  • array
  • stdClass
  • json (string)
  • xml (string)
  • SimpleXmlElement

TODO: The outstanding behaviour with initialized null by mixed types !!!!!!!!!!!!!!!

CLI

Contributors

Maintainer

Others

License

PHP Data Mapping Service is under the MIT license. See LICENSE for more information.