ah-b / oil
flexible package for manage complex domain logic
0.1
2019-05-31 12:18 UTC
Requires
None
Requires (Dev)
- phpunit/phpunit: ^7.5
Suggests
None
Provides
None
Conflicts
None
Replaces
None
This package is auto-updated.
Last update: 2026-09-15 07:42:54 UTC
README
- PHP 8.3 or later for the current development branch
Installation
composer require ah-b/oil "0.1"
Development
Install dependencies and run the test suite:
composer install
composer test
Usage
$pipelineService = new OilService(new Pipeline()); $pipelineService->add(new Test()); $pipelineService->run('my payload');
Stages are consumed by the next run() call. They are cleared whether the run
returns successfully or throws, so add the stages again for each execution.
class Test { public function __invoke($payload) { return $payload; } }
mediate
$pipelineService = new OilService(new Mediator()); $pipelineService->add(function($payload){ echo $payload; }); $pipelineService->run('my payload');
Scenario
public function indexController() { $databaseRecord = "test"; if($databaseRecord == "test") { // do some logic } if($databaseRecord == "foo") { // do some logic } if($databaseRecord == "bar") { // do some logic } ... }
public function indexController() { $databaseRecord = "test"; $pipelineService = new OilService(new Pipeline()); $pipelineService->add(new Test()); $pipelineService->add(new Foo()); $pipelineService->add(new Bar()); $pipelineService->run($databaseRecord); ... }