A Stock to keep variables and function and use them inside a pipiline system. This package is originally created to work alongside various packages by PHPallas Team. However, it is possible to use it anywhere you need a buffer object to keep your variables and functions available across steps of a pipeline.
- Install
phpallas/buffer
: by using composer you can install it on your package as below:
composer require phpallas/buffer
This will install latest version of package.
- Get an instant:
buffer
is a singleton so inside and part ot your program get the instant as following method:
use PHPallas\Buffer\Stock as Buffer;
$buffer = Buffer::getInstance();
- Set variable: you can set a variable as below
use PHPallas\Buffer\Stock as Buffer;
$buffer = Buffer::set("namespace.name", "value here");
where the name of variable MAY include some namespaces using a dot notation, for example vars.page.title
, tables.main.headers
, etc.
- Get variable: you can use a dot notation to get variable value. For example if you set an array as below:
$buffer -> set("page.title", ["title" => "great", "subTitle" => "awsome title", "separator" => "|"]);
then:
$buffer -> get("page.title.title"); // => gerat
$buffer -> get("page.title.subTitle"); // => awsome title
$buffer -> get("page.title"); // => ["title" => "great", "subTitle" => "awsome title", "separator" => "|"]
If you need a feature that is missing from my package just create an isset.
All types of contributions (development, test, translation) are welcome! you can contribute on this package and make it better and more usable.
This package is licenced under MIT.