This repository has been archived by the owner on May 15, 2020. It is now read-only.
Reversible functions are functions that can be undone. In this packages they are implemented using closures. Closures are versatile, highly portable yet small in size.
This package provides some reversible functions, currently only for encoding:
- php serialization
- json encoding
- base64 encoding
- url and raw url encoding
Also a queue is shipped with this version.
You can create a queue and use it for multi-step encoding.
Example: Serialize an object and encode in base64 for safe transport
// Build the queue
$reversibleQueue = new \CoStack\Reversible\ReversibleQueue();
$reversibleQueue->enqueue(new \CoStack\Reversible\Encoding\SerializationEncoding());
$reversibleQueue->enqueue(new \CoStack\Reversible\Encoding\Base64Encoding());
$output = $reversibleQueue->getExecutionClosure()($input);
// Transport
$input = $reversibleQueue->getReversionClosure()($output);