dev-master
9999999-devUniversal object packer and unpacker
MIT
The Requires
by hacpaka
serialization packer unpacker data-compact compactor
Wallogit.com
2017 © Pedro Peláez
Universal object packer and unpacker
This is the lightweight and high-performance library provides the simple way to transfer any objects or arrays between two applications., (*1)
Here's the simpler way to install the Eggbe/Compact package via composer:, (*2)
composer require eggbe/compact
Now we can use the library features anywhere in the code:, (*3)
$SerializedDataArray = Compactor::compact($OriginalDataArray, $FlagsCombination);
The binary flags combination define the library behavior in contentious cases.
Currently only two flags are supported: Compactor::CO_STRICT and Compactor::CO_ALLOW_ARRAYABLE.
The Compactor::CO_STRICT flag is always set by default., (*4)
In the strict mode the library requires that all objects implement the \Able\Prototypes\IPresentable interface
defined in the Able/Prototypes package. This interface provides an universal way to present an object as an array
by the simple implementation of IPresentable::present() method., (*5)
In other case when the Compactor::CO_ALLOW_ARRAYABLE flag is provided and an object don't implement the \Able\Prototypes\IPresentable interface
then the library tries to convert this object into an array via toArray() method. If this method don't exists an exception will be thrown., (*6)
The following code is return data back from the serialized representation:, (*7)
$OriginalDataArray = Compactor::decompact($SerializedDataArray, $Aliaser);
The library requires that all restorable objects implement the \Able\Prototypes\IRestorable interface
defined in the Able/Prototypes package. This interface provides an universal way to create
an object and fill its with data by the simple implementation of IRestorable constructor., (*8)
Sometimes it's important to make class overloading during the deserialization process. The second parameter of the Compactor::decompact() provids the simplest way to do it.
Please, see the Aliaser component documentation for more information., (*9)
This package is released under the MIT license., (*10)
Universal object packer and unpacker
MIT
serialization packer unpacker data-compact compactor