Rings allows you to create and dispatch sequential, decorable, filterable and/or composable pipelines.
- Benefits
- Features
- Prerequisites
- Installation
- Usage
- Documentation
- Support
- Faq
- Contributing
- Contacts
- Roadmap
- Change log
- License
- Be highly composable.
- Be immutable.
Rings are implemented as immutable chains. When you enqueue a new decorator, a new stage will be created with the added decorator.
You can enqueue decorators that add functionality to the pipeline. You can enqueue decorators that filter the operations to be done on data. You can enqueue decorators which add sub pipelines.
This makes pipelines easy to reuse, highly composable, and minimizes side-effects.
- PHP 7.2.0
Yes, that's the only hard requirement.
Use Composer
$ composer require guglielmopepe/rings
// create pipeline
$pipeline = new \Rings\Classes\Pipeline(new \SplQueue());
// add decorators:
$pipeline->addDecorator(new \Rings\Classes\Decorator(function (\Rings\Interfaces\Data $data) {echo 'Stage 1 <br />';return $data;}));
$pipeline->addDecorator(new \Rings\Classes\Decorator(function (\Rings\Interfaces\Data $data) {echo 'Stage 2 <br />';return $data;}));
$pipeline->addDecorator(new \Rings\Classes\Decorator(function (\Rings\Interfaces\Data $data) {echo 'Stage 3 <br />';return $data;}));
// execute command
$data = $pipeline->execute(new \Rings\Classes\Data([]));
// create pipeline
$pipeline = new \Rings\Classes\Pipeline(new \SplQueue());
// add decorators:
$pipeline->addDecorator(new \Rings\Classes\Decorator(
function (\Rings\Interfaces\Data $data)
{
return new \Rings\Classes\Data(['foo' => '***' . $data['foo'] . '***']);
})
);
$pipeline->addDecorator(new \Rings\Classes\Decorator(
function (\Rings\Interfaces\Data $data)
{
return new \Rings\Classes\Data(['foo' => '___' . $data['foo'] . '___']);
})
);
// execute command
$data = $pipeline->execute(new \Rings\Classes\Data(['foo' => 'bar']));
// print ___***bar***___
echo $data['foo'];
// create pipeline
$pipeline = new \Rings\Classes\Pipeline(new \SplQueue());
// add decorators:
$pipeline->addDecorator(new \Rings\Classes\Decorator(
function (\Rings\Interfaces\Data $data)
{
if (strpos($data['foo'], '***') !== FALSE)
{
return $data;
}
return new \Rings\Classes\Data(['foo' => '***' . $data['foo'] . '***']);
})
);
$pipeline->addDecorator(new \Rings\Classes\Decorator(
function (\Rings\Interfaces\Data $data)
{
if (strpos($data['foo'], '___') !== FALSE)
{
return $data;
}
return new \Rings\Classes\Data(['foo' => '___' . $data['foo'] . '___']);
})
);
// execute command
$data = $pipeline->execute(new \Rings\Classes\Data(['foo' => 'bar']));
// print ___***bar***___
echo $data['foo'];
// execute command
$data = $pipeline->execute(new \Rings\Classes\Data(['foo' => '***bar***']));
// print ***bar***
echo $data['foo'];
// execute command
$data = $pipeline->execute(new \Rings\Classes\Data(['foo' => '___bar___']));
// print ***bar***
echo $data['foo'];
If you have a request, please create a GitHub issue.
If you discover a security vulnerability, please send an email to Guglielmo Pepe at info@guglielmopepe.com. All security vulnerabilities will be promptly addressed.
To do
If you want to say thank you and/or support the active development of Rings
:
- Add a GitHub Star to the project.
- Share the project on social media.
- Write a review or tutorial on Medium, Dev.to or personal blog.
If you need information please send an email to info@guglielmopepe.com.
See the list of open issues:
Please see Changelog file for more information on what has changed recently.
Distributed under the MIT License. Please see License File for more information.