Download the PHP package exeu/objectmerger without Composer
On this page you can find all versions of the php package exeu/objectmerger. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Download exeu/objectmerger
More information about exeu/objectmerger
Files in exeu/objectmerger
Package objectmerger
Short Description Object Merger for PHP Objects.
License Apache-2.0
Homepage https://github.com/Exeu/objectmerger
Informations about the package objectmerger
Objectmerger
With this library you have the abillity to merge two objects of the same type.
This library is under construction. Things will change.
Build status
Installation
Composer
Add the objectmerger in your existing composer.json or create a new composer.json:
Now tell composer to download the library by running the command:
Composer will generate the autoloader file automaticly. So you only have to include this. Typically its located in the vendor dir and its called autoload.php
Basic Usage:
Adding mergeable metadata
Before you can merge objects you have to add some metadata about which property should be mergeable. You can achieve this out of the box by three different ways: Annotations, YAML and XML.
Annotation
YAML
Not implemented yet. If you want to contribute -> Feel free and fork this library.
XML
Not implemented yet. If you want to contribute -> Feel free and fork this library.
Using the merger
Registering CustomHandler:
A Customhandler is an own created merge handler. Creating a MergeHandler gives you the power of controlling HOW a property is beeing merged. Built in are some default mergehandler like (string, int, object, etc.). Now we are at the point to create a new merge handler. First of all you have to implement the MergeHandlerInterface.
After youve Written your handler you can simply register it in the MergeHandlerRegistry:
After attaching the MergeHandler to the Registry it is ready to use. Just add the MergeAnnotation to your property: