2017 © Pedro Peláez
 

library compact

Universal object packer and unpacker

image

eggbe/compact

Universal object packer and unpacker

  • Sunday, May 27, 2018
  • by eggbe
  • Repository
  • 1 Watchers
  • 1 Stars
  • 29 Installations
  • PHP
  • 0 Dependents
  • 0 Suggesters
  • 0 Forks
  • 0 Open issues
  • 1 Versions
  • 0 % Grown

The README.md

Introduction

This is the lightweight and high-performance library provides the simple way to transfer any objects or arrays between two applications., (*1)

Requirements

Install

Here's the simpler way to install the Eggbe/Compact package via composer:, (*2)

composer require eggbe/compact

Usage

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)

License

This package is released under the MIT license., (*10)

The Versions

27/05 2018

dev-master

9999999-dev

Universal object packer and unpacker

  Sources   Download

MIT

The Requires

 

by hacpaka

serialization packer unpacker data-compact compactor